Merge branch 'Automatic_Covers' into develop

Conflicts:
	Vocaluxe/Base/CBackgroundMusic.cs
	VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs
This commit is contained in:
Flamefire committed 2014-10-02 20:43:17 +02:00
commit f1c89b9a8e
94 files changed
+4513 -3344

No files matched your search

+39
View File
@@ -0,0 +1,39 @@
using System.Text;
namespace VocaluxeLib
{
static class CEncoding
{
public static Encoding GetEncoding(this string encodingName)
{
switch (encodingName)
{
case "AUTO":
return Encoding.Default;
case "CP1250":
return Encoding.GetEncoding(1250);
case "CP1252":
return Encoding.GetEncoding(1252);
case "LOCALE":
return Encoding.Default;
case "UTF8":
return Encoding.UTF8;
default:
return Encoding.Default;
}
}
public static string GetEncodingName(this Encoding enc)
{
string result = "UTF8";
if (enc.CodePage == 1250)
result = "CP1250";
if (enc.CodePage == 1252)
result = "CP1252";
return result;
}
}
}
+95
View File
@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.Xml.Serialization;
namespace VocaluxeLib
{
public interface IFontObserver
{
void FontChanged();
}
public struct SThemeFont
{
public string Name;
public EStyle Style;
public float Size;
}
public class CFont
{
private string _Name;
private EStyle _Style;
private float _Height;
private readonly List<IFontObserver> _Observers = new List<IFontObserver>();
public string Name
{
get { return _Name; }
set
{
if (_Name == value)
return;
_Name = value;
foreach (IFontObserver observer in _Observers)
observer.FontChanged();
}
}
public EStyle Style
{
get { return _Style; }
set
{
if (_Style == value)
return;
_Style = value;
foreach (IFontObserver observer in _Observers)
observer.FontChanged();
}
}
public float Height
{
get { return _Height; }
set
{
if (Math.Abs(_Height - value) < 0.001)
return;
_Height = value;
foreach (IFontObserver observer in _Observers)
observer.FontChanged();
}
}
public CFont()
{
_Name = "Normal";
_Style = EStyle.Normal;
_Height = 25f;
}
public CFont(SThemeFont font)
{
_Name = font.Name;
_Style = font.Style;
_Height = font.Size;
}
public CFont(string fontFamily, EStyle style, float h)
{
_Name = fontFamily;
_Style = style;
_Height = h;
}
public void AddObserver(IFontObserver observer)
{
if (!_Observers.Contains(observer))
_Observers.Add(observer);
}
public void RemoveObserver(IFontObserver observer)
{
_Observers.Remove(observer);
}
}
}
+61 -115
View File
@@ -17,11 +17,9 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Text;
namespace VocaluxeLib
{
@@ -64,46 +62,6 @@ namespace VocaluxeLib
return (int)result;
}
/// <summary>
/// Makes sure val is between min and max
/// Asserts that min&lt;=max
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns>Clamped value</returns>
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
{
Debug.Assert(min.CompareTo(max) <= 0);
if (val.CompareTo(min) < 0)
return min;
if (val.CompareTo(max) > 0)
return max;
return val;
}
/// <summary>
/// Makes sure val is between min and max but also handles the case where min&gt;max
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="preferMin"></param>
/// <returns>Clamped value</returns>
public static T Clamp<T>(this T val, T min, T max, bool preferMin) where T : IComparable<T>
{
if (min.CompareTo(max) > 0)
{
if (preferMin)
max = min;
else
min = max;
}
return Clamp(val, min, max);
}
/// <summary>
/// Concat strings into one string with ", " as separator.
/// </summary>
@@ -120,90 +78,88 @@ namespace VocaluxeLib
return result;
}
public static void SetRect(SRectF bounds, out SRectF rect, float rectAspect, EAspect aspect)
/// <summary>
/// Places a rect within the bounds maintaining the aspectRatio and using the given aspect
/// </summary>
/// <param name="bounds">Bounds to fit the rect in</param>
/// <param name="aspectRatio">The original aspectRatio of the rect/image/...</param>
/// <param name="aspect">
/// Crop: Fit fully in bounds cutting off overhanging parts (same on both sides)<br />
/// LetterBox: Fit the long side possibly leaving some space on the other (rect will be centered)<br />
/// StretcH: Just fit the rect in the bounds (rect=bounds)
/// </param>
public static SRectF FitInBounds(SRectF bounds, float aspectRatio, EAspect aspect)
{
var bounds2 = new RectangleF(bounds.X, bounds.Y, bounds.W, bounds.H);
RectangleF rect2;
SetRect(bounds2, out rect2, rectAspect, aspect);
if (aspect == EAspect.Stretch)
return bounds;
rect = new SRectF(rect2.X, rect2.Y, rect2.Width, rect2.Height, bounds.Z);
}
float boundsAspectRatio = bounds.W / bounds.H;
public static void SetRect(RectangleF bounds, out RectangleF rect, float rectAspect, EAspect aspect)
{
float boundsW = bounds.Width;
float boundsH = bounds.Height;
float boundsAspect = boundsW / boundsH;
float scaledWidth;
float scaledHeight;
float scaledWidth, scaledHeight;
switch (aspect)
{
case EAspect.Crop:
if (boundsAspect >= rectAspect)
if (boundsAspectRatio >= aspectRatio)
{
scaledWidth = boundsW;
scaledHeight = boundsW / rectAspect;
scaledWidth = bounds.W;
scaledHeight = bounds.W / aspectRatio;
}
else
{
scaledHeight = boundsH;
scaledWidth = boundsH * rectAspect;
scaledHeight = bounds.H;
scaledWidth = bounds.H * aspectRatio;
}
break;
case EAspect.Zoom1:
if (boundsAspect >= rectAspect)
if (boundsAspectRatio >= aspectRatio)
{
scaledWidth = boundsW * 1.33f;
scaledHeight = boundsW * 1.33f / rectAspect;
scaledWidth = bounds.W * 1.33f;
scaledHeight = bounds.W * 1.33f / aspectRatio;
}
else
{
scaledHeight = boundsH / 1.33f;
scaledWidth = boundsH / 1.33f * rectAspect;
scaledHeight = bounds.H / 1.33f;
scaledWidth = bounds.H / 1.33f * aspectRatio;
}
break;
case EAspect.Zoom2:
if (boundsAspect >= rectAspect)
if (boundsAspectRatio >= aspectRatio)
{
scaledWidth = boundsW * 1.17f;
scaledHeight = boundsW * 1.17f / rectAspect;
scaledWidth = bounds.W * 1.17f;
scaledHeight = bounds.W * 1.17f / aspectRatio;
}
else
{
scaledHeight = boundsH / 1.17f;
scaledWidth = boundsH / 1.17f * rectAspect;
scaledHeight = bounds.H / 1.17f;
scaledWidth = bounds.H / 1.17f * aspectRatio;
}
break;
case EAspect.LetterBox:
if (boundsAspect <= rectAspect)
if (boundsAspectRatio <= aspectRatio)
{
scaledWidth = boundsW;
scaledHeight = boundsW / rectAspect;
scaledWidth = bounds.W;
scaledHeight = bounds.W / aspectRatio;
}
else
{
scaledHeight = boundsH;
scaledWidth = boundsH * rectAspect;
scaledHeight = bounds.H;
scaledWidth = bounds.H * aspectRatio;
}
break;
default:
scaledWidth = boundsW;
scaledHeight = boundsH;
break;
return bounds;
}
float left = (bounds.W - scaledWidth) / 2 + bounds.X;
float top = (bounds.H - scaledHeight) / 2 + bounds.Y;
float left = (boundsW - scaledWidth) / 2 + bounds.Left;
float upper = (boundsH - scaledHeight) / 2 + bounds.Top;
rect = new RectangleF(left, upper, scaledWidth, scaledHeight);
return new SRectF(left, top, scaledWidth, scaledHeight, bounds.Z);
}
/// <summary>
/// Returns a list with all files in the given path that match a given pattern
/// </summary>
/// <param name="path">Path to search for</param>
/// <param name="path">Path to search</param>
/// <param name="searchPattern">Pattern to match (e.g. "*.jpg")</param>
/// <param name="recursive">Search directories recursively</param>
/// <param name="fullpath">False for just file names, True for full path</param>
@@ -301,7 +257,7 @@ namespace VocaluxeLib
public static bool IsInBounds(SRectF bounds, int x, int y)
{
return (bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y);
return ((float)x).IsInRange(bounds.X, bounds.X + bounds.W) && ((float)y).IsInRange(bounds.Y, bounds.Y + bounds.H);
}
/// <summary>
@@ -331,40 +287,30 @@ namespace VocaluxeLib
{
return (n * n + n) / 2;
}
}
static class CEncoding
{
public static Encoding GetEncoding(this string encodingName)
/// <summary>
/// Loads a bitmap from a file logging errors
/// </summary>
/// <param name="filePath">Full path to image file</param>
/// <returns>Bitmap or null on error</returns>
public static Bitmap LoadBitmap(string filePath)
{
switch (encodingName)
if (!File.Exists(filePath))
{
case "AUTO":
return Encoding.Default;
case "CP1250":
return Encoding.GetEncoding(1250);
case "CP1252":
return Encoding.GetEncoding(1252);
case "LOCALE":
return Encoding.Default;
case "UTF8":
return Encoding.UTF8;
default:
return Encoding.Default;
CBase.Log.LogError("Can't find File: " + filePath);
return null;
}
}
public static string GetEncodingName(this Encoding enc)
{
string result = "UTF8";
if (enc.CodePage == 1250)
result = "CP1250";
if (enc.CodePage == 1252)
result = "CP1252";
return result;
Bitmap bmp;
try
{
bmp = new Bitmap(filePath);
}
catch (Exception)
{
CBase.Log.LogError("Error loading bitmap: " + filePath);
return null;
}
return bmp;
}
}
}
-149
View File
@@ -1,149 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System.Drawing;
namespace VocaluxeLib.Draw
{
public class CTexture
{
public int ID = -1;
public int PBO;
//Only used by OpenGL (the texture "name" according to the specs)
public int Name = -1;
public string TexturePath = "";
/// <summary>
/// Original size (e.g. of bmp)
/// </summary>
public readonly Size OrigSize;
public float OrigAspect
{
get { return (float)OrigSize.Width / OrigSize.Height; }
}
/// <summary>
/// Current size when drawn
/// </summary>
public SRectF Rect;
public SColorF Color = new SColorF(1f, 1f, 1f, 1f);
private int _W2, _H2;
private readonly bool _UseFullTexture;
/// <summary>
/// Internal texture width (on device), a power of 2 if necessary
/// </summary>
public int W2
{
get { return _W2; }
set
{
_W2 = value;
if (_UseFullTexture)
WidthRatio = 1;
else
WidthRatio = (float)OrigSize.Width / _W2;
}
}
/// <summary>
/// Internal texture height (on device), a power of 2 if necessary
/// </summary>
public int H2
{
get { return _H2; }
set
{
_H2 = value;
if (_UseFullTexture)
HeightRatio = 1;
else
HeightRatio = (float)OrigSize.Height / _H2;
}
}
/// <summary>
/// Internal use. Specifies which part of texture memory is actually used
/// </summary>
public float WidthRatio { get; private set; }
/// <summary>
/// Internal use. Specifies which part of texture memory is actually used
/// </summary>
public float HeightRatio { get; private set; }
/// <summary>
/// Actual texture space used in x direction
/// </summary>
public int UsedWidth
{
get { return (int)(_W2 * WidthRatio); }
}
/// <summary>
/// Actual texture space used in y direction
/// </summary>
public int UsedHeight
{
get { return (int)(_H2 * HeightRatio); }
}
/*
/// <summary>
/// Internal use. Specifies if full texture memory should be used
/// Set to true if you resized the original image to the maximum
/// </summary>
public bool UseFullTexture
{
get { return _UseFullTexture; }
set
{
_UseFullTexture = value;
if (value)
{
WidthRatio = 1;
HeightRatio = 1;
}
else
{
WidthRatio = (float)OrigSize.Width / _W2;
HeightRatio = (float)OrigSize.Height / _H2;
}
}
}
*/
/// <summary>
/// Creates a new texture reference
/// </summary>
/// <param name="origWidth">Original width (Bitmap size)</param>
/// <param name="origHeight">Original height (Bitmap size)</param>
/// <param name="texWidth">Width in video memory</param>
/// <param name="texHeight">Height in video memory</param>
/// <param name="useFullTexture">True if it is using the full size of the video memory (no blank parts due to Pow-2-Issue)</param>
public CTexture(int origWidth, int origHeight, int texWidth = 0, int texHeight = 0, bool useFullTexture = false)
{
OrigSize = new Size(origWidth, origHeight);
Rect = new SRectF(0f, 0f, origWidth, origHeight, 0f);
_UseFullTexture = useFullTexture;
//IMPORTANT: Use setter here to calculate ratios!
W2 = (texWidth > 0) ? texWidth : origWidth;
H2 = (texHeight > 0) ? texHeight : origHeight;
}
}
}
+87
View File
@@ -0,0 +1,87 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Drawing;
namespace VocaluxeLib.Draw
{
/// <summary>
/// Reference to a texture in the drawing driver
/// </summary>
public class CTextureRef : IDisposable
{
public int ID { get; private set; }
/// <summary>
/// Size of original image (e.g. of bmp)
/// </summary>
public Size OrigSize;
public float OrigAspect
{
get { return (float)OrigSize.Width / OrigSize.Height; }
}
/// <summary>
/// Current size when drawn
/// </summary>
public SRectF Rect;
public SColorF Color = new SColorF(1f, 1f, 1f, 1f);
/// <summary>
/// Creates a new texture reference
/// </summary>
/// <param name="id">ID of the texture</param>
/// <param name="origSize">Original size (Bitmap size)</param>
public CTextureRef(int id, Size origSize)
{
ID = id;
OrigSize = origSize;
Rect = new SRectF(0f, 0f, origSize.Width, origSize.Height, 0f);
}
~CTextureRef()
{
Dispose();
}
public void Dispose()
{
if (ID >= 0)
{
//Free textures that are no longer referenced
CTextureRef tmp = this;
CBase.Drawing.RemoveTexture(ref tmp);
}
SetRemoved();
}
/// <summary>
/// Call this from the graphics driver to denote that this reference is remove and no longer valid <br />
/// This avoids the finalizer
/// </summary>
public void SetRemoved()
{
if (ID < 0)
throw new ObjectDisposedException(GetType().Name);
ID = -1;
GC.SuppressFinalize(this);
}
}
}
+7
View File
@@ -48,6 +48,13 @@ namespace VocaluxeLib
Zoom2
}
public enum EGeneralAlignment
{
Middle,
Start,
End
}
public enum EAlignment
{
Left,
+103 -18
View File
@@ -17,13 +17,71 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Globalization;
using System.Linq;
using System.Text.RegularExpressions;
namespace VocaluxeLib
{
public static class CExtensions
{
/// <summary>
/// Makes sure val is between min and max
/// Asserts that min&lt;=max
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns>Clamped value</returns>
public static T Clamp<T>(this T val, T min, T max) where T : IComparable<T>
{
Debug.Assert(min.CompareTo(max) <= 0);
if (val.CompareTo(min) < 0)
return min;
if (val.CompareTo(max) > 0)
return max;
return val;
}
/// <summary>
/// Makes sure val is between min and max but also handles the case where min&gt;max
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <param name="preferMin"></param>
/// <returns>Clamped value</returns>
public static T Clamp<T>(this T val, T min, T max, bool preferMin) where T : IComparable<T>
{
if (min.CompareTo(max) > 0)
{
if (preferMin)
max = min;
else
min = max;
}
return Clamp(val, min, max);
}
/// <summary>
/// Checks if the value is in the specified range
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="val"></param>
/// <param name="min"></param>
/// <param name="max"></param>
/// <returns></returns>
public static bool IsInRange<T>(this T val, T min, T max) where T : IComparable<T>
{
Debug.Assert(min.CompareTo(max) <= 0);
return min.CompareTo(val) <= 0 && max.CompareTo(val) >= 0;
}
/// <summary>
/// Resizes the given list to the given size. Removes elements or adds default values
/// </summary>
@@ -91,28 +149,13 @@ namespace VocaluxeLib
return value.IndexOf(other, StringComparison.CurrentCultureIgnoreCase) >= 0;
}
private static Regex _MultipleWhiteSpaceRegEx = new Regex(@" {2,}");
public static string TrimMultipleWs(this string value)
{
if (string.IsNullOrEmpty(value))
return "";
int start = 0;
int len = value.Length;
while (value[start] == ' ')
{
start++;
if (start >= len)
return "";
}
if (start > 0)
start--;
int end = --len;
while (value[end] == ' ')
end--;
if (end < len)
end++;
if (end - start < len)
value = value.Substring(start, end - start + 1);
return value;
return _MultipleWhiteSpaceRegEx.Replace(value, " ");
}
/// <summary>
@@ -134,5 +177,47 @@ namespace VocaluxeLib
rect.H + 2 * rect.H * (scale - 1f),
rect.Z);
}
public static Size GetSize(this Bitmap bmp)
{
return new Size(bmp.Width, bmp.Height);
}
public static Rectangle GetRect(this Bitmap bmp)
{
return Rectangle.Round(new Rectangle(0, 0, bmp.Width, bmp.Height));
}
/// <summary>
/// Resizes the bitmap to the given size creating a copy of it
/// </summary>
/// <param name="bmp"></param>
/// <param name="newSize"></param>
/// <returns>Resized bitmap or null on error</returns>
public static Bitmap Resize(this Bitmap bmp, Size newSize)
{
Bitmap result = null;
try
{
//Create a new Bitmap with the new sizes
result = new Bitmap(newSize.Width, newSize.Height);
//Scale the texture
using (Graphics g = Graphics.FromImage(result))
{
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.SmoothingMode = SmoothingMode.HighQuality;
g.DrawImage(bmp, result.GetRect());
}
}
catch (Exception)
{
if (result != null)
{
result.Dispose();
result = null;
}
}
return result;
}
}
}
+22 -26
View File
@@ -101,8 +101,8 @@ namespace VocaluxeLib
{
string GetThemeScreensPath(int partyModeID);
int GetSkinIndex(int partyModeID);
CTexture GetSkinTexture(string textureName, int partyModeID);
CTexture GetSkinVideoTexture(string videoName, int partyModeID);
CTextureRef GetSkinTexture(string textureName, int partyModeID);
CTextureRef GetSkinVideoTexture(string videoName, int partyModeID);
void SkinVideoResume(string videoName, int partyModeID);
void SkinVideoPause(string videoName, int partyModeID);
@@ -133,26 +133,27 @@ namespace VocaluxeLib
void Play();
void Stop();
CTexture GetVideoTexture();
CTextureRef GetVideoTexture();
void LoadPreview(CSong song, float start = 0f);
void PlayPreview(float start = -1f);
void StopPreview();
}
public interface IDrawing
{
void DrawTexture(CTexture texture, SRectF rect);
void DrawTexture(CTexture texture, SRectF rect, SColorF color);
void DrawTexture(CTexture texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false);
void DrawTextureReflection(CTexture texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight);
void DrawTexture(CTextureRef texture, SRectF rect);
void DrawTexture(CTextureRef texture, SRectF rect, SColorF color);
void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false);
void DrawTexture(CTextureRef textureRef, SRectF bounds, EAspect aspect);
void DrawTexture(CTextureRef textureRef, SRectF bounds, EAspect aspect, SColorF color);
void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float reflectionSpace, float reflectionHeight);
CTexture AddTexture(string fileName);
void RemoveTexture(ref CTexture texture);
CTextureRef AddTexture(string fileName);
void RemoveTexture(ref CTextureRef texture);
void DrawColor(SColorF color, SRectF rect);
void DrawColorReflection(SColorF color, SRectF rect, float space, float height);
void DrawRect(SColorF color, SRectF rect);
void DrawRectReflection(SColorF color, SRectF rect, float space, float height);
}
public interface IGraphics
@@ -175,15 +176,11 @@ namespace VocaluxeLib
public interface IFonts
{
void SetFont(string fontName);
void SetStyle(EStyle fontStyle);
RectangleF GetTextBounds(CText text);
RectangleF GetTextBounds(CText text, float textHeight);
void DrawText(string text, float textHeight, float x, float y, float z, SColorF color);
void DrawTextReflection(string text, float textHeight, float x, float y, float z, SColorF color, float reflectionSpace, float reflectionHeight);
void DrawText(string text, float textHeight, float x, float y, float z, SColorF color, float begin, float end);
void DrawText(string text, CFont font, float x, float y, float z, SColorF color);
void DrawTextReflection(string text, CFont font, float x, float y, float z, SColorF color, float reflectionSpace, float reflectionHeight);
void DrawText(string text, CFont font, float x, float y, float z, SColorF color, float begin, float end);
}
public interface ILanguage
@@ -226,7 +223,7 @@ namespace VocaluxeLib
CProfile[] GetProfiles();
EGameDifficulty GetDifficulty(int profileID);
string GetPlayerName(int profileID, int playerNum = 0);
CTexture GetAvatar(int profileID);
CTextureRef GetAvatar(int profileID);
CAvatar GetAvatarByFilename(string fileName);
bool IsProfileIDValid(int profileID);
bool IsGuest(int profileID);
@@ -267,7 +264,7 @@ namespace VocaluxeLib
{
int Load(string videoFileName);
bool Skip(int streamID, float startPosition, float videoGap);
bool GetFrame(int streamID, ref CTexture videoTexture, float time, out float videoTime);
bool GetFrame(int streamID, ref CTextureRef videoTexture, float time, out float videoTime);
bool IsFinished(int streamID);
bool Close(int streamID);
void SetLoop(int streamID, bool loop = true);
@@ -292,12 +289,12 @@ namespace VocaluxeLib
public interface ICover
{
CTexture GetNoCover();
CTextureRef GetNoCover();
}
public interface IDataBase
{
bool GetCover(string fileName, ref CTexture texture, int coverSize);
bool GetCover(string fileName, ref CTextureRef texture, int coverSize);
bool GetDataBaseSongInfos(string artist, string title, out int numPlayed, out DateTime dateAdded, out int highscoreID);
}
@@ -336,10 +333,9 @@ namespace VocaluxeLib
void Load(CSong song, float start = 0f);
void Stop();
void TogglePause();
CTexture GetCover();
CTexture GetVideoTexture();
CTextureRef GetCover();
CTextureRef GetVideoTexture();
bool IsPlaying();
float GetLength();
}
}
+44 -67
View File
@@ -16,12 +16,12 @@
#endregion
using System;
using System.Drawing;
using System.Xml;
using System.Xml.Serialization;
using System.Diagnostics;
using System.Collections.Generic;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
@@ -37,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;
}
@@ -58,7 +53,7 @@ namespace VocaluxeLib.Menu
private int _SlideShowCurrent;
private readonly Stopwatch _SlideShowTimer = new Stopwatch();
private readonly List<CTexture> _SlideShowTextures = new List<CTexture>();
private readonly List<CTextureRef> _SlideShowTextures = new List<CTextureRef>();
public SColorF Color;
public bool ThemeLoaded
@@ -149,36 +144,31 @@ namespace VocaluxeLib.Menu
CBase.Theme.SkinVideoPause(_Theme.VideoName, _PartyModeID);
}
public bool Draw()
public void Draw()
{
bool ok = false;
if (_Theme.Type == EBackgroundTypes.Video && CBase.Config.GetVideoBackgrounds() == EOffOn.TR_CONFIG_ON &&
CBase.Config.GetVideosToBackground() == EOffOn.TR_CONFIG_ON && CBase.BackgroundMusic.IsPlaying() && CBase.BackgroundMusic.SongHasVideo() &&
CBase.BackgroundMusic.VideoEnabled() && !CBase.BackgroundMusic.IsDisabled())
if (_Theme.Type == EBackgroundTypes.Video && CBase.Config.GetVideoBackgrounds() == EOffOn.TR_CONFIG_ON)
{
Pause();
ok = _DrawBackgroundMusicVideo();
if (CBase.Config.GetVideosToBackground() == EOffOn.TR_CONFIG_ON && CBase.BackgroundMusic.IsPlaying() && CBase.BackgroundMusic.SongHasVideo() &&
CBase.BackgroundMusic.VideoEnabled())
{
Pause();
ok = _DrawBackgroundMusicVideo();
}
else
{
Resume();
ok = _DrawVideo();
}
}
else if (_Theme.Type == EBackgroundTypes.Video && CBase.Config.GetVideoBackgrounds() == EOffOn.TR_CONFIG_ON)
{
Resume();
ok = _DrawVideo();
}
if (_Theme.Type == EBackgroundTypes.SlideShow && _Theme.SlideShowTextures.Count > 0)
else if (_Theme.Type == EBackgroundTypes.SlideShow && _Theme.SlideShowTextures.Count > 0)
ok = _DrawSlideShow();
if (!String.IsNullOrEmpty(_Theme.TextureName) &&
(_Theme.Type == EBackgroundTypes.Texture ||
(_Theme.Type == EBackgroundTypes.Video && CBase.Config.GetVideoBackgrounds() == EOffOn.TR_CONFIG_OFF)))
if (!String.IsNullOrEmpty(_Theme.TextureName) && (_Theme.Type == EBackgroundTypes.Texture || !ok))
ok = _DrawTexture();
if (_Theme.Type == EBackgroundTypes.Color || _Theme.Type == EBackgroundTypes.Texture && !ok ||
(_Theme.Type == EBackgroundTypes.Video && CBase.Config.GetVideoBackgrounds() == EOffOn.TR_CONFIG_OFF && !ok))
if (_Theme.Type == EBackgroundTypes.Color || !ok)
_DrawColor();
return true;
}
public void UnloadTextures()
@@ -200,7 +190,7 @@ namespace VocaluxeLib.Menu
_Theme.Type = EBackgroundTypes.SlideShow;
if (!String.IsNullOrEmpty(image))
{
CTexture texture = CBase.Drawing.AddTexture(image);
CTextureRef texture = CBase.Drawing.AddTexture(image);
if (texture != null)
_SlideShowTextures.Add(texture);
}
@@ -208,9 +198,9 @@ namespace VocaluxeLib.Menu
public void RemoveSlideShowTextures()
{
foreach (CTexture tex in _SlideShowTextures)
foreach (CTextureRef tex in _SlideShowTextures)
{
CTexture texture = tex;
CTextureRef texture = tex;
CBase.Drawing.RemoveTexture(ref texture);
}
_SlideShowTextures.Clear();
@@ -229,23 +219,22 @@ namespace VocaluxeLib.Menu
#endregion public
#region internal
private static SRectF _GetDrawRect()
{
return new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4);
}
private void _DrawColor()
{
var bounds = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4);
CBase.Drawing.DrawColor(Color, bounds);
CBase.Drawing.DrawRect(Color, _GetDrawRect());
}
private bool _DrawTexture()
{
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
CTextureRef texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
if (texture != null)
{
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
CBase.Drawing.DrawTexture(texture, _GetDrawRect(), EAspect.Crop);
return true;
}
return false;
@@ -266,20 +255,16 @@ namespace VocaluxeLib.Menu
_SlideShowTimer.Restart();
if (_SlideShowCurrent + 1 < _SlideShowTextures.Count)
_SlideShowCurrent++;
else if (_SlideShowCurrent != 0)
else
_SlideShowCurrent = 0;
}
CTexture texture = _SlideShowTextures[_SlideShowCurrent];
CTextureRef texture = _SlideShowTextures[_SlideShowCurrent];
if (texture == null)
return false;
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
CBase.Drawing.DrawTexture(texture, _GetDrawRect(), EAspect.Crop);
if (_SlideShowTimer.ElapsedMilliseconds >= CBase.Settings.GetSlideShowImageTime())
{
@@ -292,9 +277,9 @@ namespace VocaluxeLib.Menu
if (texture != null)
{
float alpha = (_SlideShowTimer.ElapsedMilliseconds - CBase.Settings.GetSlideShowImageTime()) / CBase.Settings.GetSlideShowFadeTime();
CHelper.SetRect(bounds, out rect, texture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(texture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, (CBase.Settings.GetZFar() / 4) - 1), new SColorF(1, 1, 1, alpha));
SColorF color = texture.Color;
color.A = (_SlideShowTimer.ElapsedMilliseconds - CBase.Settings.GetSlideShowImageTime()) / CBase.Settings.GetSlideShowFadeTime();
CBase.Drawing.DrawTexture(texture, _GetDrawRect(), EAspect.Crop, color);
}
}
@@ -305,14 +290,10 @@ namespace VocaluxeLib.Menu
private bool _DrawVideo()
{
CTexture videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID);
CTextureRef videoTexture = CBase.Theme.GetSkinVideoTexture(_Theme.VideoName, _PartyModeID);
if (videoTexture != null)
{
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(videoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
CBase.Drawing.DrawTexture(videoTexture, _GetDrawRect(), EAspect.Crop);
return true;
}
return false;
@@ -320,14 +301,10 @@ namespace VocaluxeLib.Menu
private bool _DrawBackgroundMusicVideo()
{
CTexture videoTexture = CBase.BackgroundMusic.GetVideoTexture();
CTextureRef videoTexture = CBase.BackgroundMusic.GetVideoTexture();
if (videoTexture != null)
{
var bounds = new RectangleF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH());
RectangleF rect;
CHelper.SetRect(bounds, out rect, videoTexture.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(videoTexture, new SRectF(rect.X, rect.Y, rect.Width, rect.Height, CBase.Settings.GetZFar() / 4));
CBase.Drawing.DrawTexture(videoTexture, _GetDrawRect(), EAspect.Crop);
return true;
}
return false;
+16 -25
View File
@@ -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
@@ -54,8 +46,8 @@ namespace VocaluxeLib.Menu
private bool _ThemeLoaded;
private readonly int _PartyModeID;
public CTexture Texture;
public CTexture SelTexture;
public CTextureRef Texture;
public CTextureRef SelTexture;
public SRectF Rect;
public SColorF Color;
public SColorF SelColor;
@@ -257,13 +249,12 @@ namespace VocaluxeLib.Menu
return _ThemeLoaded;
}
public void Draw(bool forceDraw = false)
{
if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme && !forceDraw)
return;
CTexture texture;
CTextureRef texture;
if (!Selected && !Pressed || !_Enabled)
{
@@ -273,7 +264,7 @@ namespace VocaluxeLib.Menu
if (_Reflection)
{
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, Rect, _ReflectionSpace, _ReflectionHeight);
CBase.Drawing.DrawTextureReflection(texture, Rect, Color, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
}
else
@@ -287,7 +278,7 @@ namespace VocaluxeLib.Menu
if (_Reflection)
{
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight);
Text.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
}
else
@@ -301,7 +292,7 @@ namespace VocaluxeLib.Menu
if (_Reflection)
{
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, Rect, _ReflectionSpace, _ReflectionHeight);
CBase.Drawing.DrawTextureReflection(texture, Rect, SelColor, _ReflectionSpace, _ReflectionHeight);
_SelText.DrawRelative(Rect.X, Rect.Y, _ReflectionHeight, _ReflectionSpace, Rect.H);
}
else
+14 -23
View File
@@ -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
@@ -249,10 +240,10 @@ namespace VocaluxeLib.Menu
if (i == _MaxBar)
color = MaxColor;
CBase.Drawing.DrawColor(color, bar);
CBase.Drawing.DrawRect(color, bar);
if (Reflection)
CBase.Drawing.DrawColorReflection(color, bar, ReflectionSpace, ReflectionHeight);
CBase.Drawing.DrawRectReflection(color, bar, ReflectionSpace, ReflectionHeight);
}
}
@@ -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;
+10 -16
View File
@@ -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,10 +189,7 @@ namespace VocaluxeLib.Menu
private void _SetText(CSongNote note)
{
_Text.Text = note.Text;
_Text.Style = EStyle.Bold;
if (note.Type == ENoteType.Freestyle)
_Text.Style = EStyle.BoldItalic;
_Text.Font.Style = (note.Type == ENoteType.Freestyle) ? EStyle.BoldItalic : EStyle.Bold;
}
public void Clear()
@@ -337,11 +331,11 @@ namespace VocaluxeLib.Menu
p = 1f - p;
float ty = _Text.Y;
float th = _Text.Height;
float th = _Text.Font.Height;
float tz = _Text.Z;
SRectF normalRect = _Text.Rect;
_Text.Height += _Text.Height * 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;
@@ -351,7 +345,7 @@ namespace VocaluxeLib.Menu
_Text.Draw();
_Text.Y = ty;
_Text.Height = th;
_Text.Font.Height = th;
_Text.Z = tz;
}
}
@@ -443,7 +437,7 @@ namespace VocaluxeLib.Menu
else
{
float y = _Text.Y;
_Text.Y -= _Text.Height * 0.1f * p;
_Text.Y -= _Text.Font.Height * 0.1f * p;
_Text.Draw();
_Text.Y = y;
}
+3 -2
View File
@@ -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
{
@@ -587,7 +588,7 @@ namespace VocaluxeLib.Menu
return new CStatic(oldStatic);
}
public CStatic GetNewStatic(CTexture texture, SColorF color, SRectF rect)
public CStatic GetNewStatic(CTextureRef texture, SColorF color, SRectF rect)
{
return new CStatic(_PartyModeID, texture, color, rect);
}
@@ -632,7 +633,7 @@ namespace VocaluxeLib.Menu
return new CPlaylist(_PartyModeID);
}
public CParticleEffect GetNewParticleEffect(int maxNumber, SColorF color, SRectF area, CTexture texture, float size, EParticleType type)
public CParticleEffect GetNewParticleEffect(int maxNumber, SColorF color, SRectF area, CTextureRef texture, float size, EParticleType type)
{
return new CParticleEffect(_PartyModeID, maxNumber, color, area, texture, size, type);
}
+1 -1
View File
@@ -683,7 +683,7 @@ namespace VocaluxeLib.Menu
for (int i = 0; i < _TeamList[_CurrentTeam].Count; i++)
{
string name = CBase.Profiles.GetPlayerName(_TeamList[_CurrentTeam][i]);
CTexture avatar = CBase.Profiles.GetAvatar(_TeamList[_CurrentTeam][i]);
CTextureRef avatar = CBase.Profiles.GetAvatar(_TeamList[_CurrentTeam][i]);
_SelectSlides[_SelectSlidePlayer].AddValue(name, avatar);
}
for (int i = _TeamList[_CurrentTeam].Count; i < _NumPlayerTeams[_CurrentTeam]; i++)
+26 -42
View File
@@ -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
@@ -110,16 +93,15 @@ namespace VocaluxeLib.Menu
public SRectF Rect;
private readonly List<CTile> _Tiles;
private CTexture _TextureEmptyTile;
private CTexture _TextureTileSelected;
public CTexture TextureEmptyTile
private CTextureRef _TextureEmptyTile;
private CTextureRef _TextureTileSelected;
public CTextureRef TextureEmptyTile
{
get { return _TextureEmptyTile; }
}
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));
}
+12 -20
View File
@@ -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
@@ -58,7 +52,7 @@ namespace VocaluxeLib.Menu
#region private vars
private readonly int _PartyModeID;
private readonly string _TextureName;
private readonly CTexture _Texture;
private readonly CTextureRef _Texture;
private SRectF _Rect;
private float _Size;
private SColorF _Color;
@@ -141,7 +135,7 @@ namespace VocaluxeLib.Menu
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
}
public CParticle(int partyModeID, CTexture texture, SColorF color, float x, float y, float size, float maxage, float z, float vx, float vy, float vr, float vsize,
public CParticle(int partyModeID, CTextureRef texture, SColorF color, float x, float y, float size, float maxage, float z, float vx, float vy, float vr, float vsize,
EParticleType type)
{
_PartyModeID = partyModeID;
@@ -159,8 +153,6 @@ namespace VocaluxeLib.Menu
_MaxAge = maxage;
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
}
#endregion Constructors
public void Update()
@@ -316,7 +308,7 @@ namespace VocaluxeLib.Menu
private SThemeParticleEffect _Theme;
private bool _ThemeLoaded;
public CTexture Texture;
public CTextureRef Texture;
public SColorF Color;
public SRectF Rect;
@@ -370,7 +362,7 @@ namespace VocaluxeLib.Menu
Visible = true;
}
public CParticleEffect(int partyModeID, int maxNumber, SColorF color, SRectF rect, CTexture texture, float size, EParticleType type)
public CParticleEffect(int partyModeID, int maxNumber, SColorF color, SRectF rect, CTextureRef texture, float size, EParticleType type)
{
_PartyModeID = partyModeID;
_Theme = new SThemeParticleEffect();
+26 -42
View File
@@ -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();
}
@@ -405,7 +389,7 @@ namespace VocaluxeLib.Menu
public bool IsMouseOver(SMouseEvent mouseEvent)
{
return CHelper.IsInBounds(CompleteRect, mouseEvent.X, mouseEvent.Y) || _Interactions.IsMouseOver(mouseEvent);
return CHelper.IsInBounds(CompleteRect, mouseEvent) || _Interactions.IsMouseOver(mouseEvent);
}
public void UnloadTextures()
+5 -7
View File
@@ -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
@@ -131,7 +129,7 @@ namespace VocaluxeLib.Menu
}
}
private CTexture _GetTextureValue(string value)
private CTextureRef _GetTextureValue(string value)
{
return CBase.Theme.GetSkinTexture(value, _PartyModeID);
}
+42 -68
View File
@@ -18,75 +18,50 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Xml;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
[XmlType("SelectSlide")]
public struct SThemeSelectSlide
{
[XmlAttributeAttribute(AttributeName = "Name")]
public string Name;
[XmlAttribute(AttributeName = "Name")] public string Name;
[XmlElement("Skin")]
public string TextureName;
[XmlElement("SkinArrowLeft")]
public string TextureArrowLeftName;
[XmlElement("SkinArrowRight")]
public string TextureArrowRightName;
[XmlElement("Skin")] public string TextureName;
[XmlElement("SkinArrowLeft")] public string TextureArrowLeftName;
[XmlElement("SkinArrowRight")] public string TextureArrowRightName;
[XmlElement("SkinSelected")]
public string SelTextureName;
[XmlElement("SkinArrowLeftSelected")]
public string SelTextureArrowLeftName;
[XmlElement("SkinArrowRightSelected")]
public string SelTextureArrowRightName;
[XmlElement("SkinSelected")] public string SelTextureName;
[XmlElement("SkinArrowLeftSelected")] public string SelTextureArrowLeftName;
[XmlElement("SkinArrowRightSelected")] public string SelTextureArrowRightName;
[XmlElement("SkinHighlighted")]
public string HighlightTextureName;
[XmlElement("SkinHighlighted")] public string HighlightTextureName;
[XmlElement("Rect")]
public SRectF Rect;
[XmlElement("RectArrowLeft")]
public SRectF RectArrowLeft;
[XmlElement("RectArrowRight")]
public SRectF RectArrowRight;
[XmlElement("Rect")] public SRectF Rect;
[XmlElement("RectArrowLeft")] public SRectF RectArrowLeft;
[XmlElement("RectArrowRight")] public SRectF RectArrowRight;
[XmlElement("Color")]
public SThemeColor Color;
[XmlElement("SColor")]
public SThemeColor SColor;
[XmlElement("HColor")]
public SThemeColor HColor;
[XmlElement("Color")] public SThemeColor Color;
[XmlElement("SColor")] public SThemeColor SColor;
[XmlElement("HColor")] public SThemeColor HColor;
[XmlElement("ArrowColor")]
public SThemeColor ArrowColor;
[XmlElement("ArrowSColor")]
public SThemeColor ArrowSColor;
[XmlElement("ArrowColor")] public SThemeColor ArrowColor;
[XmlElement("ArrowSColor")] public SThemeColor ArrowSColor;
[XmlElement("TextColor")]
public SThemeColor TextColor;
[XmlElement("TextSColor")]
public SThemeColor TextSColor;
[XmlElement("TextColor")] public SThemeColor TextColor;
[XmlElement("TextSColor")] public SThemeColor TextSColor;
[XmlElement("TextH")]
public float TextH;
[XmlElement("TextRelativeX")]
public float TextRelativeX;
[XmlElement("TextRelativeY")]
public float TextRelativeY;
[XmlElement("TextMaxW")]
public float TextMaxW;
[XmlElement("TextH")] public float TextH;
[XmlElement("TextRelativeX")] public float TextRelativeX;
[XmlElement("TextRelativeY")] public float TextRelativeY;
[XmlElement("TextMaxW")] public float TextMaxW;
[XmlElement("TextFont")]
public string TextFont;
[XmlElement("TextStyle")]
public EStyle TextStyle;
[XmlElement("TextFont")] public string TextFont;
[XmlElement("TextStyle")] public EStyle TextStyle;
[XmlElement("NumVisible")]
public int NumVisible;
[XmlElement("NumVisible")] public int NumVisible;
}
public class CSelectSlide : IMenuElement, ICloneable
@@ -154,7 +129,7 @@ namespace VocaluxeLib.Menu
private readonly List<string> _ValueNames;
private readonly List<int> _ValuePartyModeIDs;
private readonly List<CTexture> _Textures;
private readonly List<CTextureRef> _Textures;
private readonly List<int> _ValueIndexes;
private readonly List<SRectF> _ValueBounds = new List<SRectF>();
@@ -222,7 +197,7 @@ namespace VocaluxeLib.Menu
MaxW = 0f;
_Selected = false;
_Textures = new List<CTexture>();
_Textures = new List<CTextureRef>();
_ValueIndexes = new List<int>();
_ValueNames = new List<string>();
_ValuePartyModeIDs = new List<int>();
@@ -270,7 +245,7 @@ namespace VocaluxeLib.Menu
MaxW = slide.MaxW;
_Selected = slide._Selected;
_Textures = new List<CTexture>(slide._Textures);
_Textures = new List<CTextureRef>(slide._Textures);
_ValueIndexes = new List<int>(slide._ValueIndexes);
_ValueNames = new List<string>(slide._ValueNames);
_ValueBounds = new List<SRectF>(slide._ValueBounds);
@@ -288,7 +263,7 @@ namespace VocaluxeLib.Menu
_Theme = theme;
_Selected = false;
_Textures = new List<CTexture>();
_Textures = new List<CTextureRef>();
_ValueIndexes = new List<int>();
_ValueNames = new List<string>();
_ValuePartyModeIDs = new List<int>();
@@ -444,17 +419,17 @@ namespace VocaluxeLib.Menu
AddValue(value, null, _ValueIndexes.Count, partyModeID);
}
public void AddValue(string value, CTexture texture)
public void AddValue(string value, CTextureRef texture)
{
AddValue(value, texture, _ValueIndexes.Count, _PartyModeID);
}
private void _AddValue(string value, CTexture texture, int valueIndex)
private void _AddValue(string value, CTextureRef texture, int valueIndex)
{
AddValue(value, texture, valueIndex, _PartyModeID);
}
public void AddValue(string value, CTexture texture, int valueIndex, int partyModeID)
public void AddValue(string value, CTextureRef texture, int valueIndex, int partyModeID)
{
_ValueNames.Add(value);
_Textures.Add(texture);
@@ -475,7 +450,7 @@ namespace VocaluxeLib.Menu
_ValueBounds.Clear();
}
public void AddValues(string[] values, CTexture[] textures)
public void AddValues(string[] values, CTextureRef[] textures)
{
if (values.Length != textures.Length)
return;
@@ -499,7 +474,7 @@ namespace VocaluxeLib.Menu
RenameValue(Selection, newName);
}
public void RenameValue(int selection, string newName, CTexture newTexture = null)
public void RenameValue(int selection, string newName, CTextureRef newTexture = null)
{
if (selection < 0 && selection >= _ValueNames.Count)
return;
@@ -623,15 +598,15 @@ namespace VocaluxeLib.Menu
if (!Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
return;
CTexture texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
CTexture textureArrowLeft = CBase.Theme.GetSkinTexture(_Theme.TextureArrowLeftName, _PartyModeID);
CTexture textureArrowRight = CBase.Theme.GetSkinTexture(_Theme.TextureArrowRightName, _PartyModeID);
CTextureRef texture = CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
CTextureRef textureArrowLeft = CBase.Theme.GetSkinTexture(_Theme.TextureArrowLeftName, _PartyModeID);
CTextureRef textureArrowRight = CBase.Theme.GetSkinTexture(_Theme.TextureArrowRightName, _PartyModeID);
CTexture selTexture = CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
CTexture selTextureArrowLeft = CBase.Theme.GetSkinTexture(_Theme.SelTextureArrowLeftName, _PartyModeID);
CTexture selTextureArrowRight = CBase.Theme.GetSkinTexture(_Theme.SelTextureArrowRightName, _PartyModeID);
CTextureRef selTexture = CBase.Theme.GetSkinTexture(_Theme.SelTextureName, _PartyModeID);
CTextureRef selTextureArrowLeft = CBase.Theme.GetSkinTexture(_Theme.SelTextureArrowLeftName, _PartyModeID);
CTextureRef selTextureArrowRight = CBase.Theme.GetSkinTexture(_Theme.SelTextureArrowRightName, _PartyModeID);
CTexture highlightTexture = CBase.Theme.GetSkinTexture(_Theme.HighlightTextureName, _PartyModeID);
CTextureRef highlightTexture = CBase.Theme.GetSkinTexture(_Theme.HighlightTextureName, _PartyModeID);
if (Selected)
{
@@ -773,7 +748,6 @@ namespace VocaluxeLib.Menu
TextRelativeX = _Theme.TextRelativeX;
TextRelativeY = _Theme.TextRelativeY;
MaxW = _Theme.TextMaxW;
}
public void ReloadTextures()
+21 -24
View File
@@ -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;
@@ -51,8 +50,8 @@ namespace VocaluxeLib.Menu
get { return _ThemeLoaded; }
}
private CTexture _Texture;
public CTexture Texture
private CTextureRef _Texture;
public CTextureRef Texture
{
get { return _Texture ?? CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); }
@@ -73,10 +72,7 @@ namespace VocaluxeLib.Menu
public EAspect Aspect = EAspect.Stretch;
public CStatic()
{
}
public CStatic() {}
public CStatic(int partyModeID)
{
@@ -99,7 +95,7 @@ namespace VocaluxeLib.Menu
Visible = s.Visible;
}
public CStatic(int partyModeID, CTexture texture, SColorF color, SRectF rect)
public CStatic(int partyModeID, CTextureRef texture, SColorF color, SRectF rect)
{
_PartyModeID = partyModeID;
@@ -179,26 +175,27 @@ namespace VocaluxeLib.Menu
public void Draw(EAspect aspect, float scale = 1f, float zModify = 0f, bool forceDraw = false)
{
CTexture texture = Texture ?? new CTexture((int)Rect.W, (int)Rect.H);
SRectF bounds = Rect.Scale(scale);
SRectF rect;
if (aspect != EAspect.Stretch)
CHelper.SetRect(bounds, out rect, texture.OrigAspect, aspect);
else
rect = bounds;
rect.Z = Rect.Z + zModify;
CTextureRef texture = Texture;
SRectF rect = Rect.Scale(scale);
rect.Z += zModify;
if (texture != null)
rect = CHelper.FitInBounds(rect, texture.OrigAspect, aspect);
var color = new SColorF(Color.R, Color.G, Color.B, Color.A * Alpha);
if (Visible || forceDraw || (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
{
CBase.Drawing.DrawTexture(texture, rect, color, bounds);
if (Reflection)
CBase.Drawing.DrawTextureReflection(texture, rect, color, bounds, ReflectionSpace, ReflectionHeight);
if (texture != null)
{
CBase.Drawing.DrawTexture(texture, rect, color);
if (Reflection)
CBase.Drawing.DrawTextureReflection(texture, rect, color, ReflectionSpace, ReflectionHeight);
}
else
CBase.Drawing.DrawRect(color, rect);
}
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
CBase.Drawing.DrawColor(new SColorF(1f, 1f, 1f, 0.5f), rect);
CBase.Drawing.DrawRect(new SColorF(1f, 1f, 1f, 0.5f), rect);
}
public void UnloadTextures() {}
+56 -101
View File
@@ -17,43 +17,32 @@
using System;
using System.Drawing;
using System.Xml;
using System.Xml.Serialization;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
[XmlType("Text")]
public struct SThemeText
{
[XmlAttributeAttribute(AttributeName = "Name")]
public string Name;
[XmlAttribute(AttributeName = "Name")] public string Name;
[XmlElement("X")]
public float X;
[XmlElement("Y")]
public float Y;
[XmlElement("Z")]
public float Z;
[XmlElement("H")]
public float Height;
[XmlElement("MaxW")]
public float MaxWidth;
[XmlElement("X")] public float X;
[XmlElement("Y")] public float Y;
[XmlElement("Z")] public float Z;
[XmlElement("H")] public float FontHeight;
[XmlElement("MaxW")] public float MaxWidth;
public SThemeColor Color;
public SThemeColor SColor; //for Buttons
[XmlElement("Align")]
public EAlignment Align;
[XmlElement("ResizeAlign")]
public EHAlignment ResizeAlign;
[XmlElement("Style")]
public EStyle Style;
[XmlElement("Font")]
public string Font;
[XmlElement("Text")]
public string Text;
[XmlElement("Align")] public EAlignment Align;
[XmlElement("ResizeAlign")] public EHAlignment ResizeAlign;
[XmlElement("Style")] public EStyle FontStyle;
[XmlElement("Font")] public string FontFamily;
[XmlElement("Text")] public string Text;
public SReflection Reflection;
}
public class CText : IMenuElement
public class CText : IMenuElement, IFontObserver
{
private SThemeText _Theme;
private bool _ThemeLoaded;
@@ -110,20 +99,6 @@ namespace VocaluxeLib.Menu
set { _Z = value; }
}
private float _Height;
public float Height
{
get { return _Height; }
set
{
if (Math.Abs(_Height - value) > 0.01)
{
_Height = value;
_PositionNeedsUpdate = true;
}
}
}
private float _MaxWidth;
public float MaxWidth
{
@@ -166,29 +141,17 @@ namespace VocaluxeLib.Menu
}
}
private EStyle _Style = EStyle.Normal;
public EStyle Style
{
get { return _Style; }
set
{
if (_Style != value)
{
_Style = value;
_PositionNeedsUpdate = true;
}
}
}
private string _Font = String.Empty;
public string Font
private CFont _Font = new CFont();
public CFont Font
{
get { return _Font; }
set
{
if (_Font != value)
if (!_Font.Equals(value))
{
_Font.RemoveObserver(this);
_Font = value;
_Font.AddObserver(this);
_PositionNeedsUpdate = true;
}
}
@@ -227,10 +190,16 @@ namespace VocaluxeLib.Menu
_Text = translation;
if (_EditMode)
_Text += "|";
//Reset height, it might have been reduced in _UpdatePosition
Font.Height = _Theme.FontHeight;
_PositionNeedsUpdate = true;
}
}
}
public string TranslatedText
{
get { return _Text; }
}
public int PartyModeID
{
@@ -274,7 +243,7 @@ namespace VocaluxeLib.Menu
{
_PartyModeID = partyModeID;
_TranslationID = _PartyModeID;
_Font = "Normal";
_Font.AddObserver(this);
}
public CText(CText text)
@@ -285,12 +254,10 @@ namespace VocaluxeLib.Menu
_X = text._X;
_Y = text._Y;
_Z = text._Z;
_Height = text._Height;
_MaxWidth = text._MaxWidth;
_Align = text._Align;
_ResizeAlign = text._ResizeAlign;
_Style = text._Style;
_Font = text._Font;
Font = text.Font; //Use setter to set observer
Color = new SColorF(text.Color);
SelColor = new SColorF(text.SelColor);
@@ -305,24 +272,23 @@ namespace VocaluxeLib.Menu
_EditMode = text._EditMode;
}
public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string font, SColorF col, string text, int partyModeID = -1, float rheight = 0,
float rspace = 0)
public CText(float x, float y, float z, float h, float mw, EAlignment align, EStyle style, string fontFamily, SColorF col, string text, int partyModeID = -1,
float rheight = 0,
float rspace = 0) : this(partyModeID)
{
_Theme = new SThemeText();
_Theme = new SThemeText {FontFamily = fontFamily, FontStyle = style, FontHeight = h, Text = text};
_ThemeLoaded = false;
_ButtonText = false;
_PartyModeID = partyModeID;
_TranslationID = _PartyModeID;
X = x;
Y = y;
Z = z;
Height = h;
MaxWidth = mw;
Align = align;
ResizeAlign = EHAlignment.Center;
Style = style;
Font = font;
_Font.Name = fontFamily;
_Font.Style = style;
_Font.Height = h;
Color = col;
SelColor = new SColorF(col);
@@ -362,7 +328,6 @@ namespace VocaluxeLib.Menu
if (!buttonText)
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Height);
xmlReader.TryGetFloatValue(item + "/MaxW", ref _MaxWidth);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
@@ -389,8 +354,9 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Align", ref _Align);
xmlReader.TryGetEnumValue(item + "/ResizeAlign", ref _ResizeAlign);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Style);
_ThemeLoaded &= xmlReader.GetValue(item + "/Font", out _Font, "Normal");
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.FontHeight);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.FontStyle);
_ThemeLoaded &= xmlReader.GetValue(item + "/Font", out _Theme.FontFamily);
_ThemeLoaded &= xmlReader.GetValue(item + "/Text", out _Theme.Text, String.Empty);
@@ -407,15 +373,12 @@ namespace VocaluxeLib.Menu
_Theme.Name = elementName;
_Theme.Align = _Align;
_Theme.Color.Color = Color;
_Theme.Font = _Font;
_Theme.ResizeAlign = _ResizeAlign;
_Theme.SColor.Color = SelColor;
_Theme.Style = _Style;
_Theme.MaxWidth = _MaxWidth;
_Theme.X = _X;
_Theme.Y = _Y;
_Theme.Z = _Z;
_Theme.Height = _Height;
_ButtonText = buttonText;
_PositionNeedsUpdate = true;
@@ -425,7 +388,6 @@ namespace VocaluxeLib.Menu
return _ThemeLoaded;
}
public void Draw(bool forceDraw = false)
{
if (!forceDraw && !Visible && CBase.Settings.GetProgramState() != EProgramState.EditTheme)
@@ -434,30 +396,24 @@ namespace VocaluxeLib.Menu
// Update Text
Text = Text;
CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style);
SColorF currentColor = (Selected) ? SelColor : Color;
var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
CBase.Fonts.DrawText(_Text, Rect.H, Rect.X, Rect.Y, Z, color);
CBase.Fonts.DrawText(_Text, Font, Rect.X, Rect.Y, Z, color);
if (ReflectionHeight > 0)
CBase.Fonts.DrawTextReflection(_Text, Rect.H, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight);
CBase.Fonts.DrawTextReflection(_Text, Font, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight);
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z));
CBase.Drawing.DrawRect(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z));
}
public void Draw(float begin, float end)
{
CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style);
SColorF currentColor = (Selected) ? SelColor : Color;
var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha);
CBase.Fonts.DrawText(Text, Rect.H, Rect.X, Rect.Y, Z, color, begin, end);
CBase.Fonts.DrawText(Text, Font, Rect.X, Rect.Y, Z, color, begin, end);
if (ReflectionHeight > 0)
{
@@ -465,7 +421,7 @@ namespace VocaluxeLib.Menu
}
if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme))
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(X, Y, Rect.W, Rect.H, Z));
CBase.Drawing.DrawRect(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(X, Y, Rect.W, Rect.H, Z));
}
public void DrawRelative(float rx, float ry, float reflectionHeight = 0f, float reflectionSpace = 0f, float rectHeight = 0f)
@@ -505,12 +461,10 @@ namespace VocaluxeLib.Menu
_X = _Theme.X;
_Y = _Theme.Y;
_Z = _Theme.Z;
_Height = _Theme.Height;
_MaxWidth = _Theme.MaxWidth;
_Align = _Theme.Align;
_ResizeAlign = _Theme.ResizeAlign;
_Style = _Theme.Style;
_Font = _Theme.Font;
Font = new CFont(_Theme.FontFamily, _Theme.FontStyle, _Theme.FontHeight);
if (_Theme.Reflection.Enabled)
{
@@ -541,17 +495,16 @@ namespace VocaluxeLib.Menu
X += stepX;
Y += stepY;
_Theme.X += stepX;
_Theme.Y += stepY;
_Theme.X = X;
_Theme.Y = Y;
}
public void ResizeElement(int stepW, int stepH)
{
Height += stepH;
if (Height <= 0)
Height = 1;
_Theme.Height = _Height;
_Theme.FontHeight += stepH;
if (_Theme.FontHeight <= 0)
_Theme.FontHeight = 1;
_Font.Height = _Theme.FontHeight;
}
#endregion ThemeEdit
@@ -560,10 +513,7 @@ namespace VocaluxeLib.Menu
if (_Text == "")
return;
CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style);
float h = Height;
float h = Font.Height;
float y = Y;
RectangleF bounds = CBase.Fonts.GetTextBounds(this);
@@ -584,8 +534,8 @@ namespace VocaluxeLib.Menu
y += step * 0.75f;
break;
}
bounds = CBase.Fonts.GetTextBounds(this, h);
Font.Height = h;
bounds = CBase.Fonts.GetTextBounds(this);
}
float x = X;
@@ -606,5 +556,10 @@ namespace VocaluxeLib.Menu
_PositionNeedsUpdate = false;
}
public void FontChanged()
{
_PositionNeedsUpdate = true;
}
}
}
+1
View File
@@ -16,6 +16,7 @@
#endregion
using System.Xml;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu
{
+41 -56
View File
@@ -18,10 +18,10 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SingNotes
{
@@ -42,42 +42,30 @@ namespace VocaluxeLib.Menu.SingNotes
}
[XmlType("Position")]
public struct SBarPosition
public struct SBarPosition
{
[XmlAttributeAttribute(AttributeName = "Name")]
public string Name;
[XmlAttribute(AttributeName = "Name")] public string Name;
public SRectF Rect;
}
[XmlType("SingBar")]
public struct SThemeSingBar
{
[XmlAttributeAttribute(AttributeName = "Name")]
public string Name;
[XmlAttribute(AttributeName = "Name")] public string Name;
[XmlElement("SkinLeft")]
public string SkinLeftName;
[XmlElement("SkinMiddle")]
public string SkinMiddleName;
[XmlElement("SkinRight")]
public string SkinRightName;
[XmlElement("SkinLeft")] public string SkinLeftName;
[XmlElement("SkinMiddle")] public string SkinMiddleName;
[XmlElement("SkinRight")] public string SkinRightName;
[XmlElement("SkinBackgroundLeft")]
public string SkinBackgroundLeftName;
[XmlElement("SkinBackgroundMiddle")]
public string SkinBackgroundMiddleName;
[XmlElement("SkinBackgroundRight")]
public string SkinBackgroundRightName;
[XmlElement("SkinBackgroundLeft")] public string SkinBackgroundLeftName;
[XmlElement("SkinBackgroundMiddle")] public string SkinBackgroundMiddleName;
[XmlElement("SkinBackgroundRight")] public string SkinBackgroundRightName;
[XmlElement("SkinGoldenStar")]
public string SkinGoldenStarName;
[XmlElement("SkinToneHelper")]
public string SkinToneHelperName;
[XmlElement("SkinPerfectNoteStart")]
public string SkinPerfectNoteStarName;
[XmlElement("SkinGoldenStar")] public string SkinGoldenStarName;
[XmlElement("SkinToneHelper")] public string SkinToneHelperName;
[XmlElement("SkinPerfectNoteStart")] public string SkinPerfectNoteStarName;
[XmlArray("BarPositions")]
public SBarPosition[] BarPos;
[XmlArray("BarPositions")] public SBarPosition[] BarPos;
}
public abstract class CSingNotes : IMenuElement
@@ -116,7 +104,7 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes = new List<SPlayerNotes>();
_ActID = 0;
BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(), CBase.Settings.GetMaxNumPlayer()];
BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
LoadTextures();
}
@@ -152,21 +140,18 @@ namespace VocaluxeLib.Menu.SingNotes
BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
for (int numplayer = 0; numplayer < CBase.Settings.GetMaxNumPlayer(); numplayer++)
{
for (int player = 0; player < CBase.Settings.GetMaxNumPlayer(); player++)
for (int player = 0; player <= numplayer; player++)
{
if (player <= numplayer)
{
BarPos[player, numplayer] = new SRectF();
string target = "/BarPositions/P" + (player + 1) + "N" + (numplayer + 1);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "X", ref BarPos[player, numplayer].X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Y", ref BarPos[player, numplayer].Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Z", ref BarPos[player, numplayer].Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "W", ref BarPos[player, numplayer].W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "H", ref BarPos[player, numplayer].H);
_Theme.BarPos[i].Name = "P" + (player + 1) + "N" + (numplayer + 1);
_Theme.BarPos[i].Rect = new SRectF(BarPos[player, numplayer]);
i++;
}
BarPos[player, numplayer] = new SRectF();
string target = "/BarPositions/P" + (player + 1) + "N" + (numplayer + 1);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "X", ref BarPos[player, numplayer].X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Y", ref BarPos[player, numplayer].Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Z", ref BarPos[player, numplayer].Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "W", ref BarPos[player, numplayer].W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "H", ref BarPos[player, numplayer].H);
_Theme.BarPos[i].Name = "P" + (player + 1) + "N" + (numplayer + 1);
_Theme.BarPos[i].Rect = new SRectF(BarPos[player, numplayer]);
i++;
}
}
@@ -179,7 +164,6 @@ namespace VocaluxeLib.Menu.SingNotes
return _ThemeLoaded;
}
public void Reset()
{
_PlayerNotes.Clear();
@@ -317,7 +301,7 @@ namespace VocaluxeLib.Menu.SingNotes
);
_DrawNoteBG(rect, color, 1f, _PlayerNotes[n].Timer);
_DrawNote(rect, new SColorF(5f, 5f, 5f, 0.7f * _PlayerNotes[n].Alpha), 0.7f);
_DrawNote(rect, new SColorF(1f, 1f, 1f, 0.7f * _PlayerNotes[n].Alpha), 0.7f);
if (note.Type == ENoteType.Golden)
{
@@ -428,7 +412,7 @@ namespace VocaluxeLib.Menu.SingNotes
public void UnloadTextures() {}
public void LoadTextures()
public void LoadTextures()
{
foreach (SBarPosition bp in _Theme.BarPos)
{
@@ -471,9 +455,9 @@ namespace VocaluxeLib.Menu.SingNotes
var noteRect = new SRectF(rect.X + dw, rect.Y + dh, rect.W - 2 * dw, rect.H - 2 * dh, rect.Z);
CTexture noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
CTexture noteMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinMiddleName, _PartyModeID);
CTexture noteEnd = CBase.Theme.GetSkinTexture(_Theme.SkinRightName, _PartyModeID);
CTextureRef noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
CTextureRef noteMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinMiddleName, _PartyModeID);
CTextureRef noteEnd = CBase.Theme.GetSkinTexture(_Theme.SkinRightName, _PartyModeID);
//Width of each of the ends (round parts)
//Need 2 of them so use minimum
@@ -518,9 +502,9 @@ namespace VocaluxeLib.Menu.SingNotes
rect.Z
);
CTexture noteBackgroundBegin = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundLeftName, _PartyModeID);
CTexture noteBackgroundMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundMiddleName, _PartyModeID);
CTexture noteBackgroundEnd = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundRightName, _PartyModeID);
CTextureRef noteBackgroundBegin = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundLeftName, _PartyModeID);
CTextureRef noteBackgroundMiddle = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundMiddleName, _PartyModeID);
CTextureRef noteBackgroundEnd = CBase.Theme.GetSkinTexture(_Theme.SkinBackgroundRightName, _PartyModeID);
float dx = r.H * noteBackgroundBegin.OrigAspect;
if (2 * dx > r.W)
@@ -538,12 +522,13 @@ namespace VocaluxeLib.Menu.SingNotes
CBase.Drawing.DrawTexture(noteBackgroundEnd, new SRectF(r.X + r.W - dx, r.Y, dx, r.H, r.Z), col);
}
protected void _DrawNoteLines(SRectF rect, SColorF color)
private static void _DrawNoteLines(SRectF rect, SColorF color)
{
for (int i = 0; i < CBase.Settings.GetNumNoteLines() - 1; i++)
SRectF lineRect = new SRectF(rect) {H = 1.5f};
for (int i = 0; i < CBase.Settings.GetNumNoteLines(); i++)
{
float y = rect.Y + rect.H / CBase.Settings.GetNumNoteLines() * (i + 1);
CBase.Drawing.DrawColor(color, new SRectF(rect.X, y, rect.W, 1, -1.0f));
lineRect.Y = rect.Y + rect.H / CBase.Settings.GetNumNoteLines() * (i + 1);
CBase.Drawing.DrawRect(color, lineRect);
}
}
@@ -613,7 +598,7 @@ namespace VocaluxeLib.Menu.SingNotes
rect.Z
);
CTexture noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
CTextureRef noteBegin = CBase.Theme.GetSkinTexture(_Theme.SkinLeftName, _PartyModeID);
float dx = r.H * noteBegin.OrigAspect;
if (2 * dx > r.W)
dx = r.W / 2;
@@ -670,7 +655,7 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes[n].Color.B,
_PlayerNotes[n].Color.A * _PlayerNotes[n].Alpha);
CTexture toneHelper = CBase.Theme.GetSkinTexture(_Theme.SkinToneHelperName, _PartyModeID);
CTextureRef toneHelper = CBase.Theme.GetSkinTexture(_Theme.SkinToneHelperName, _PartyModeID);
CBase.Drawing.DrawTexture(toneHelper, drawRect, color);
+1
View File
@@ -17,6 +17,7 @@
using System.Xml;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu
{
+11 -38
View File
@@ -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,7 +268,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
public virtual void OnShow() {}
public virtual void OnHide()
{
if(CBase.Graphics.GetNextScreen() != EScreens.ScreenNames || CBase.Config.GetBackgroundMusicStatus() == EBackgroundMusicOffOn.TR_CONFIG_OFF)
@@ -373,7 +347,6 @@ namespace VocaluxeLib.Menu.SongMenu
_ColorInternal = CBase.Theme.GetColor(_Theme.Color.Name, _PartyModeID);
else
_ColorInternal = _Theme.Color.Color;
}
public void ReloadTextures()
@@ -17,13 +17,13 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using System.Xml;
using VocaluxeLib.Draw;
using VocaluxeLib.PartyModes;
using VocaluxeLib.Songs;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Menu.SongMenu
{
@@ -38,8 +38,8 @@ namespace VocaluxeLib.Menu.SongMenu
private CStatic _MedleyCalcIcon;
private CStatic _MedleyTagIcon;
private CTexture _CoverBigBGTexture;
private CTexture _CoverBGTexture;
private CTextureRef _CoverBigBGTexture;
private CTextureRef _CoverBGTexture;
private CText _Artist;
private CText _Title;
@@ -494,20 +494,16 @@ namespace VocaluxeLib.Menu.SongMenu
_TextBG.Draw();
CTexture vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null;
CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null;
if (vidtex != null)
{
if (vidtex.Color.A < 1)
_CoverBig.Draw(EAspect.Crop);
var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H);
RectangleF rect;
CHelper.SetRect(bounds, out rect, vidtex.OrigAspect, EAspect.Crop);
var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z);
var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f);
SRectF rect = CHelper.FitInBounds(_CoverBig.Rect, vidtex.OrigAspect, EAspect.Crop);
CBase.Drawing.DrawTexture(vidtex, vidRect, vidtex.Color, vidRectBounds);
CBase.Drawing.DrawTextureReflection(vidtex, vidRect, vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
CBase.Drawing.DrawTexture(vidtex, rect);
CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight);
}
else
_CoverBig.Draw(EAspect.Crop);
+1 -3
View File
@@ -32,11 +32,9 @@ namespace VocaluxeLib.PartyModes
public override void LoadTheme(string xmlPath)
{
_Warning = GetNewText();
_Warning.Height = 100f;
_Warning.Font.Height = 100f;
_Warning.X = 150;
_Warning.Y = 300;
_Warning.Font = "Normal";
_Warning.Style = EStyle.Normal;
_Warning.Color = new SColorF(1f, 0f, 0f, 1f);
_Warning.SelColor = new SColorF(1f, 0f, 0f, 1f);
_Warning.Text = "SOMETHING WENT WRONG!";
+4 -4
View File
@@ -25,10 +25,10 @@ namespace VocaluxeLib.Profile
{
public int ID;
private readonly string _FileName = "";
private CTexture _Texture;
private CTextureRef _Texture;
private const int _MaxNameLen = 12;
public CTexture Texture
public CTextureRef Texture
{
get { return _Texture; }
}
@@ -39,11 +39,11 @@ namespace VocaluxeLib.Profile
public static CAvatar GetAvatar(string fileName)
{
CTexture texture = CBase.Drawing.AddTexture(fileName);
CTextureRef texture = CBase.Drawing.AddTexture(fileName);
return texture == null ? null : new CAvatar(texture, fileName);
}
private CAvatar(CTexture texture, string fileName, int id = -1)
private CAvatar(CTextureRef texture, string fileName, int id = -1)
{
_Texture = texture;
_FileName = fileName;
+1
View File
@@ -18,6 +18,7 @@
using System;
using System.IO;
using System.Xml;
using VocaluxeLib.Xml;
namespace VocaluxeLib.Profile
{
+4 -4
View File
@@ -24,8 +24,8 @@ namespace VocaluxeLib.Songs
public class CCategory
{
public readonly string Name;
private CTexture _CoverTextureSmall;
private CTexture _CoverTextureBig;
private CTextureRef _CoverTextureSmall;
private CTextureRef _CoverTextureBig;
public readonly List<CSongPointer> Songs = new List<CSongPointer>();
public CCategory(string name)
@@ -33,14 +33,14 @@ namespace VocaluxeLib.Songs
Name = name;
}
public CTexture CoverTextureSmall
public CTextureRef CoverTextureSmall
{
get { return _CoverTextureSmall; }
set { _CoverTextureSmall = value; }
}
public CTexture CoverTextureBig
public CTextureRef CoverTextureBig
{
get { return _CoverTextureBig ?? _CoverTextureSmall; }
set
+4 -4
View File
@@ -78,8 +78,8 @@ namespace VocaluxeLib.Songs
public partial class CSong
{
private CTexture _CoverTextureSmall;
private CTexture _CoverTextureBig;
private CTextureRef _CoverTextureSmall;
private CTextureRef _CoverTextureBig;
public SMedley Medley;
@@ -104,7 +104,7 @@ namespace VocaluxeLib.Songs
public bool NotesLoaded { get; private set; }
public CTexture CoverTextureSmall
public CTextureRef CoverTextureSmall
{
get
{
@@ -116,7 +116,7 @@ namespace VocaluxeLib.Songs
set { _CoverTextureSmall = value; }
}
public CTexture CoverTextureBig
public CTextureRef CoverTextureBig
{
get { return _CoverTextureBig ?? _CoverTextureSmall; }
set { _CoverTextureBig = value; }
+100 -16
View File
@@ -17,6 +17,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Contracts;
using System.Drawing;
using System.Windows.Forms;
@@ -25,21 +26,57 @@ 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
{
[XmlElement("R")]
public float R;
[XmlElement("G")]
public float G;
[XmlElement("B")]
public float B;
[XmlElement("A")]
public float A;
[XmlElement("R")] public float R;
[XmlElement("G")] public float G;
[XmlElement("B")] public float B;
[XmlElement("A")] public float A;
public SColorF(float r, float g, float b, float a)
{
Debug.Assert(r.IsInRange(0, 1) && g.IsInRange(0, 1) && b.IsInRange(0, 1));
Debug.Assert(a.IsInRange(0, 1));
R = r;
G = g;
B = b;
@@ -69,14 +106,30 @@ namespace VocaluxeLib
public string Name;
//Needed for serialization
public bool ColorSpecified { get { return String.IsNullOrEmpty(Name); } }
public bool NameSpecified { get { return !String.IsNullOrEmpty(Name); } }
public bool ColorSpecified
{
get { return String.IsNullOrEmpty(Name); }
}
public bool NameSpecified
{
get { return !String.IsNullOrEmpty(Name); }
}
public SThemeColor(SThemeColor theme)
{
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
@@ -86,8 +139,24 @@ namespace VocaluxeLib
public float W;
public float H;
public float Z;
[XmlIgnore]
public float Rotation; //0..360°
[XmlIgnore] public float Rotation; //0..360°
public float Right
{
get { return X + W; }
}
public float Bottom
{
get { return Y + H; }
}
public Size SizeI
{
get { return new Size((int)W, (int)H); }
}
public SizeF Size
{
get { return new SizeF(W, H); }
}
public SRectF(float x, float y, float w, float h, float z)
{
@@ -108,19 +177,34 @@ namespace VocaluxeLib
Z = rect.Z;
Rotation = 0f;
}
public SRectF(Rectangle rect)
{
X = rect.X;
Y = rect.Y;
W = rect.Width;
H = rect.Height;
Z = 0;
Rotation = 0;
}
}
[XmlRoot("Reflection")]
public struct SReflection
{
[XmlAttributeAttribute(AttributeName = "Enabled")]
public bool Enabled;
[XmlAttribute(AttributeName = "Enabled")] public bool Enabled;
public float Height;
public float Space;
//Needed for serialization
public bool HeightSpecified { get { return Enabled; } }
public bool SpaceSpecified { get { return Enabled; } }
public bool HeightSpecified
{
get { return Enabled; }
}
public bool SpaceSpecified
{
get { return Enabled; }
}
public SReflection(bool enabled, float height, float space)
{
+10 -15
View File
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using VocaluxeLib.Draw;
using VocaluxeLib.Songs;
@@ -14,7 +13,7 @@ namespace VocaluxeLib.Utils.Player
private CSong _Song;
private bool _VideoEnabled;
private int _Video = -1;
private CTexture _CurrentVideoTexture;
private CTextureRef _CurrentVideoTexture;
private CFading _VideoFading;
public bool VideoEnabled
@@ -41,7 +40,7 @@ namespace VocaluxeLib.Utils.Player
}
public bool SongHasVideo
{
get { return _Song != null && File.Exists(Path.Combine(_Song.Folder,_Song.VideoFileName)); }
get { return _Song != null && File.Exists(Path.Combine(_Song.Folder, _Song.VideoFileName)); }
}
public string ArtistAndTitle
@@ -56,7 +55,7 @@ namespace VocaluxeLib.Utils.Player
}
}
public CTexture Cover
public CTextureRef Cover
{
get { return _Song == null ? CBase.Cover.GetNoCover() : _Song.CoverTextureBig; }
}
@@ -66,11 +65,10 @@ namespace VocaluxeLib.Utils.Player
get { return _StreamID != -1; }
}
public CSongPlayer(bool loop = false) : base(loop) { }
public CSongPlayer(bool loop = false) : base(loop) {}
public CSongPlayer(CSong song, bool loop = false, float position = 0f, bool autoplay = false)
: base(Path.Combine(song.Folder,song.MP3FileName), loop, position, autoplay)
: base(Path.Combine(song.Folder, song.MP3FileName), loop, position, autoplay)
{
_Song = song;
_LoadVideo();
@@ -82,7 +80,7 @@ namespace VocaluxeLib.Utils.Player
_Song = null;
}
public CTexture GetVideoTexture()
public CTextureRef GetVideoTexture()
{
if (_Video == -1 || _Song == null)
return null;
@@ -101,7 +99,7 @@ namespace VocaluxeLib.Utils.Player
return null;
}
public void Load(CSong song, float position = 0f, bool autoplay = false)
public void Load(CSong song, float position = 0f, bool autoplay = false)
{
if (song == null)
return;
@@ -109,7 +107,7 @@ namespace VocaluxeLib.Utils.Player
Stop();
_Song = song;
base.Load(Path.Combine(song.Folder, song.MP3FileName), position, false);
_LoadVideo();
@@ -155,13 +153,10 @@ namespace VocaluxeLib.Utils.Player
CBase.Video.Pause(_Video);
CBase.Video.Skip(_Video, CBase.Sound.GetPosition(_StreamID) + _FadeTime, _Song.VideoGap);
}
else if(_Video != -1)
{
else if (_Video != -1)
CBase.Video.Resume(_Video);
}
base.TogglePause();
}
private void _LoadVideo()
{
@@ -182,4 +177,4 @@ namespace VocaluxeLib.Utils.Player
}
}
}
}
}
+6 -2
View File
@@ -76,7 +76,9 @@
<Reference Include="System.XML" />
</ItemGroup>
<ItemGroup>
<Compile Include="CEncoding.cs" />
<Compile Include="CFading.cs" />
<Compile Include="CFont.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="GlobalSuppressions.cs" />
<Compile Include="IBasic.cs" />
@@ -100,8 +102,9 @@
<Compile Include="Menu\CStatic.cs" />
<Compile Include="Menu\CText.cs" />
<Compile Include="Menu\CScreenSetting.cs" />
<Compile Include="Draw\CTexture.cs" />
<Compile Include="CXMLReader.cs" />
<Compile Include="Draw\CTextureRef.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" />
@@ -137,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,55 +57,17 @@ 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);
}
public bool TryGetColorFromRGBA(string xPath, ref SColorF value)
{
bool result = true;
result &= TryGetFloatValue(xPath + "/R", ref value.R);
result &= TryGetFloatValue(xPath + "/G", ref value.G);
result &= TryGetFloatValue(xPath + "/B", ref value.B);
result &= TryGetFloatValue(xPath + "/A", ref value.A);
if (result)
{
value.R = value.R.Clamp(0f, 1f);
value.G = value.G.Clamp(0f, 1f);
value.B = value.B.Clamp(0f, 1f);
value.A = value.A.Clamp(0f, 1f);
}
result &= TryGetNormalizedFloatValue(xPath + "/R", ref value.R);
result &= TryGetNormalizedFloatValue(xPath + "/G", ref value.G);
result &= TryGetNormalizedFloatValue(xPath + "/B", ref value.B);
result &= TryGetNormalizedFloatValue(xPath + "/A", ref value.A);
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;
@@ -128,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>();
+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;
}
}
}