Merge pull request #118 from Flamefire/develop

Develop
This commit is contained in:
Stephan Sundermann committed 2014-12-03 22:19:14 +01:00
commit d9f677cbc4
55 files changed
+576 -2630

No files matched your search

@@ -108,8 +108,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public SData GameData;
private EStage _Stage;
public CPartyModeChallenge(int id, string folder)
: base(id, folder)
public CPartyModeChallenge(int id, string folder) : base(id, folder)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using VocaluxeLib.Game;
using VocaluxeLib.Menu;
@@ -113,8 +114,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public SData GameData;
private EStage _Stage;
public CPartyModeChallengeMedley(int id, string folder)
: base(id, folder)
public CPartyModeChallengeMedley(int id, string folder) : base(id, folder)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
@@ -387,9 +387,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
}
//Calc avarage sing-count
int totalCounts = 0;
foreach (CSong song in visibleSongs)
totalCounts += song.NumPlayedSession;
int totalCounts = visibleSongs.Sum(song => song.NumPlayedSession);
int averageCount = totalCounts / visibleSongs.Count;
// ReSharper disable LoopCanBeConvertedToQuery
@@ -114,8 +114,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public SData GameData;
private EStage _Stage;
public CPartyModeTicTacToe(int id, string folder)
: base(id, folder)
public CPartyModeTicTacToe(int id, string folder) : base(id, folder)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
+3 -2
View File
@@ -104,8 +104,9 @@ namespace ServerLib
IPEndPoint groupEp = new IPEndPoint(IPAddress.Any, _Port);
listener.Client.ReceiveTimeout = timeout;
byte[] bytes = listener.Receive(ref groupEp);
string message = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
//byte[] bytes =
listener.Receive(ref groupEp);
//string message = Encoding.UTF8.GetString(bytes, 0, bytes.Length);
foundSomething = true;
if (!knownServer.Contains(groupEp.Address.ToString()))
+1 -2
View File
@@ -138,8 +138,7 @@ namespace ServerLib
return CServer.GetProfileData(profileId, isReadonly);
}
else
return new SProfileData();
return new SProfileData();
}
public SProfileData[] GetProfileList()
+2 -1
View File
@@ -69,9 +69,10 @@ namespace ServerLib
[DataContract]
public class CBase64Image
{
// ReSharper disable InconsistentNaming
[DataMember] private string base64Data = "";
[DataMember] private string imageId = "";
// ReSharper restore InconsistentNaming
public CBase64Image(Image img, ImageFormat format)
{
+2
View File
@@ -22,6 +22,7 @@ namespace ServerLib
[Flags]
enum EUserRoles
{
// ReSharper disable InconsistentNaming
TR_USERROLE_GUEST = 0,
TR_USERROLE_NORMAL = 1,
TR_USERROLE_ADMIN = 2,
@@ -29,5 +30,6 @@ namespace ServerLib
TR_USERROLE_ADDSONGSUSER = 8,
TR_USERROLE_PLAYLISTEDITOR = 16,
TR_USERROLE_PROFILEEDITOR = 32
// ReSharper restore InconsistentNaming
}
}
+1
View File
@@ -3,6 +3,7 @@
<s:String x:Key="/Default/CodeEditing/GenerateMemberBody/MethodImplementationKind/@EntryValue">NotCompiledCode</s:String>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/CodeCompletion/IntelliSenseCompletingCharacters/IntelliSenseCompletingCharactersSettingCSharp/UpgradedFromVSSettings/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeEditing/Intellisense/LookupWindow/ShowSignatures/@EntryValue">True</s:Boolean>
<s:Boolean x:Key="/Default/CodeInspection/ExcludedFiles/FileMasksToSkip/=_002A_002Ejs/@EntryIndexedValue">True</s:Boolean>
<s:String x:Key="/Default/CodeInspection/Highlighting/AnalysisEnabled/@EntryValue">SOLUTION</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=EmptyGeneralCatchClause/@EntryIndexedValue">DO_NOT_SHOW</s:String>
<s:String x:Key="/Default/CodeInspection/Highlighting/InspectionSeverities/=RedundantExplicitArrayCreation/@EntryIndexedValue">DO_NOT_SHOW</s:String>
+3 -2
View File
@@ -162,8 +162,7 @@ namespace Vocaluxe.Base
_SongPlayer = new CSongPlayer();
_PreviewPlayer = new CSongPlayer();
_PreviewPlayer.RepeatSong = true;
_PreviewPlayer = new CSongPlayer {RepeatSong = true};
_VideoEnabled = (CConfig.Config.Video.VideoBackgrounds == EOffOn.TR_CONFIG_ON && CConfig.Config.Video.VideosToBackground == EOffOn.TR_CONFIG_ON);
SetMusicSource(CConfig.Config.Sound.BackgroundMusicSource);
@@ -339,8 +338,10 @@ namespace Vocaluxe.Base
if (song == null)
return;
// ReSharper disable CompareOfFloatsByEqualityOperator
if (start == 0f)
start = song.Preview.StartTime;
// ReSharper restore CompareOfFloatsByEqualityOperator
_PlaysPreview = true;
CSound.SetGlobalVolume(CConfig.PreviewMusicVolume);
-1
View File
@@ -19,7 +19,6 @@ using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
-1
View File
@@ -20,7 +20,6 @@
using System;
using System.Collections.Generic;
using Vocaluxe.Screens;
using Vocaluxe.SongQueue;
using VocaluxeLib;
using VocaluxeLib.Game;
+2
View File
@@ -220,6 +220,8 @@ namespace Vocaluxe.Base
}
else
NextScreen.OnShow();
if (_Cursor.IsActive)
NextScreen.ProcessMouseMove(_Cursor.X, _Cursor.Y);
HidePopup(EPopupScreens.PopupPlayerControl);
}
+2 -1
View File
@@ -92,7 +92,8 @@ namespace Vocaluxe.Base
if (value == -1 || _IsCatIndexValid(value))
{
_CatIndex = value;
OnCategoryChanged();
if (OnCategoryChanged != null)
OnCategoryChanged();
}
}
}
+8 -12
View File
@@ -69,23 +69,20 @@ namespace Vocaluxe.Base
public static void Pause()
{
if (_Webcam == null)
return;
_Webcam.Pause();
if (_Webcam != null)
_Webcam.Pause();
}
public static void Start()
{
if (_Webcam == null)
return;
_Webcam.Start();
if (_Webcam != null)
_Webcam.Start();
}
public static void Stop()
{
if (_Webcam == null)
return;
_Webcam.Stop();
if (_Webcam != null)
_Webcam.Stop();
}
public static bool Select(SWebcamConfig c)
@@ -95,9 +92,8 @@ namespace Vocaluxe.Base
public static void DeSelect()
{
if (_Webcam == null)
return;
_Webcam.DeSelect();
if (_Webcam != null)
_Webcam.DeSelect();
}
public static SWebcamDevice[] GetDevices()
+8 -4
View File
@@ -192,7 +192,7 @@ namespace Vocaluxe.Base.Server
{
bool result = false;
foreach (char key in keyString.ToCharArray())
foreach (char key in keyString)
{
Controller.AddKeyEvent(new SKeyEvent(ESender.Keyboard, isAltPressed,
Char.IsUpper(key) || isShiftPressed,
@@ -697,10 +697,14 @@ namespace Vocaluxe.Base.Server
IEnumerable<int> playerIds = (from p in CProfiles.GetProfiles()
where String.Equals(p.PlayerName, username, StringComparison.OrdinalIgnoreCase)
select p.ID);
if (!playerIds.Any())
try
{
return playerIds.First();
}
catch (InvalidOperationException)
{
throw new ArgumentException("Invalid playername");
return playerIds.First();
}
}
private static byte[] _Hash(byte[] password, byte[] salt)
+3 -2
View File
@@ -30,7 +30,7 @@ namespace Vocaluxe.Base.ThemeSystem
private static readonly List<CTheme> _Themes = new List<CTheme>();
public static string[] ThemeNames
{
get { return _Themes.Select(th => th.Name).ToArray(); }
get { return _Themes.Where(th=>th is CBaseTheme).Select(th => th.Name).Distinct().ToArray(); }
}
public static string[] SkinNames
@@ -164,7 +164,8 @@ namespace Vocaluxe.Base.ThemeSystem
public static string GetThemeScreensPath(int partyModeID)
{
return CurrentThemes[partyModeID].GetScreenPath();
CTheme theme;
return CurrentThemes.TryGetValue(partyModeID, out theme) ? theme.GetScreenPath() : null;
}
private static void _LogMissingElement(int partyModeID, string elType, string elName)
+2 -18
View File
@@ -16,7 +16,6 @@
#endregion
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Vocaluxe
@@ -24,29 +23,14 @@ namespace Vocaluxe
static class COSFunctions
{
#if WIN
private static bool _DefaultDllDirSet;
private static bool _UsePath;
private static bool _UseSetDllDir;
private static class CWindowsFunctions
{
[DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void AddDllDirectory(string lpPathName);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, CallingConvention = CallingConvention.StdCall)]
public static extern void SetDllDirectory(string lpPathName);
// ReSharper disable MemberHidesStaticFromOuterClass
[DllImport("user32.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);
[DllImport("kernel32.dll", CallingConvention = CallingConvention.StdCall)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetDefaultDllDirectories(int directoryFlags);
// ReSharper disable InconsistentNaming
public const int LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000;
// ReSharper restore InconsistentNaming
// ReSharper restore MemberHidesStaticFromOuterClass
}
#endif
@@ -240,15 +240,13 @@ namespace Vocaluxe.Lib.Sound.Playback.PortAudio
if (!_FileOpened || _Terminated || !IsPaused)
return;
IsPaused = false;
_PaHandle.CheckError("StartStream", PortAudioSharp.PortAudio.Pa_StartStream(_Stream));
}
public override void Stop()
{
if (!_FileOpened || _Terminated)
return;
_Paused = true;
_PaHandle.CheckError("StopStream (playback)", PortAudioSharp.PortAudio.Pa_StopStream(_Stream));
IsPaused = true;
Position = 0f;
}
@@ -1,71 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
namespace Vocaluxe.Lib.Sound.Record.PitchTracker
{
/// <summary>
/// Pitchtracker (Pt) in C# that uses IIR filters for smoothing and an intelligent detection algorithm to reduce calculations
/// DO NOT USE in 32 Bit! Due to floating point errors the filter will raise all values to NAN (TODO: FIX it!)
/// </summary>
class CPtSharp : CPitchTracker
{
private Pitch.PitchTracker _Instance;
public CPtSharp()
{
_Instance = new Pitch.PitchTracker {SampleRate = 44100, DetectLevelThreshold = 0.01f, PitchRecordHistorySize = 1};
}
public override void Input(byte[] data)
{
short[] samplesShort = new short[data.Length / 2];
Buffer.BlockCopy(data, 0, samplesShort, 0, data.Length);
float[] samplesFloat = new float[samplesShort.Length];
for (int i = 0; i < samplesShort.Length; i++)
samplesFloat[i] = (float)samplesShort[i] / short.MaxValue;
_Instance.ProcessBuffer(samplesFloat);
}
public override int GetNote(out float maxVolume, float[] weights)
{
int note = _Instance.CurrentPitchRecord.MidiNote - 15 - 21;
maxVolume = _Instance.LastMaxVol;
_SetWeights(note, weights);
return note;
}
public override int GetNumHalfTones()
{
return NumHalfTonesDef;
}
public override float VolumeTreshold
{
get { return _Instance.DetectLevelThreshold; }
set { _Instance.DetectLevelThreshold = value; }
}
protected override void _Dispose(bool disposing)
{
if (_Instance == null)
throw new ObjectDisposedException(GetType().Name);
_Instance = null;
}
}
}
@@ -1,173 +0,0 @@
using System;
namespace Vocaluxe.Lib.Sound.Record.PitchTracker.Pitch
{
public class CircularBuffer<T> : IDisposable
{
int m_bufSize;
int m_begBufOffset;
int m_availBuf;
long m_startPos; // total circular buffer position
T[] m_buffer;
/// <summary>
/// Constructor
/// </summary>
public CircularBuffer()
{
}
/// <summary>
/// Constructor
/// </summary>
/// <param name="bufCount"></param>
public CircularBuffer(int bufCount)
{
SetSize(bufCount);
}
/// <summary>
/// Dispose
/// </summary>
public void Dispose()
{
SetSize(0);
}
/// <summary>
/// Reset to the beginning of the buffer
/// </summary>
public void Reset()
{
m_begBufOffset = 0;
m_availBuf = 0;
m_startPos = 0;
}
/// <summary>
/// Set the buffer to the specified size
/// </summary>
/// <param name="newSize"></param>
public void SetSize(int newSize)
{
Reset();
if (m_bufSize == newSize)
return;
if (m_buffer != null)
m_buffer = null;
m_bufSize = newSize;
if (m_bufSize > 0)
m_buffer = new T[m_bufSize];
}
/// <summary>
/// Clear the buffer
/// </summary>
public void Clear()
{
Array.Clear(m_buffer, 0, m_buffer.Length);
}
/// <summary>
/// Get or set the start position
/// </summary>
public long StartPosition
{
get { return m_startPos; }
set { m_startPos = value; }
}
/// <summary>
/// Get the end position
/// </summary>
public long EndPosition
{
get { return m_startPos + m_availBuf; }
}
/// <summary>
/// Get or set the amount of avaliable space
/// </summary>
public int Available
{
get { return m_availBuf; }
set { m_availBuf = Math.Min(value, m_bufSize); }
}
/// <summary>
/// Write data into the buffer
/// </summary>
/// <param name="m_pInBuffer"></param>
/// <param name="count"></param>
/// <returns></returns>
public int WriteBuffer(T[] m_pInBuffer, int count)
{
count = Math.Min(count, m_bufSize);
var startPos = m_availBuf != m_bufSize ? m_availBuf : m_begBufOffset;
var pass1Count = Math.Min(count, m_bufSize - startPos);
var pass2Count = count - pass1Count;
PitchDsp.CopyBuffer(m_pInBuffer, 0, m_buffer, startPos, pass1Count);
if (pass2Count > 0)
PitchDsp.CopyBuffer(m_pInBuffer, pass1Count, m_buffer, 0, pass2Count);
if (pass2Count == 0)
{
// did not wrap around
if (m_availBuf != m_bufSize)
m_availBuf += count; // have never wrapped around
else
{
m_begBufOffset += count;
m_startPos += count;
}
}
else
{
// wrapped around
if (m_availBuf != m_bufSize)
m_startPos += pass2Count; // first time wrap-around
else
m_startPos += count;
m_begBufOffset = pass2Count;
m_availBuf = m_bufSize;
}
return count;
}
/// <summary>
/// Read from the buffer
/// </summary>
/// <param name="outBuffer"></param>
/// <param name="startRead"></param>
/// <param name="readCount"></param>
/// <returns></returns>
public bool ReadBuffer(T[] outBuffer, long startRead, int readCount)
{
var endRead = (int)(startRead + readCount);
var endAvail = (int)(m_startPos + m_availBuf);
if (startRead < m_startPos || endRead > endAvail)
return false;
var startReadPos = (int)(((startRead - m_startPos) + m_begBufOffset) % m_bufSize);
var block1Samples = Math.Min(readCount, m_bufSize - startReadPos);
var block2Samples = readCount - block1Samples;
PitchDsp.CopyBuffer(m_buffer, startReadPos, outBuffer, 0, block1Samples);
if (block2Samples > 0)
PitchDsp.CopyBuffer(m_buffer, 0, outBuffer, block1Samples, block2Samples);
return true;
}
}
}
@@ -1,105 +0,0 @@
using System;
namespace Vocaluxe.Lib.Sound.Record.PitchTracker.Pitch
{
public static class Extensions
{
/// <summary>
/// Clear the buffer
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="buffer"></param>
public static void Clear(this float[] buffer)
{
Array.Clear(buffer, 0, buffer.Length);
}
/// <summary>
/// Clear the buffer
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="buffer"></param>
public static void Clear(this double[] buffer)
{
Array.Clear(buffer, 0, buffer.Length);
}
/// <summary>
/// Copy the values from one buffer to a different or the same buffer.
/// It is safe to copy to the same buffer, even if the areas overlap
/// </summary>
/// <param name="buffer"></param>
/// <param name="shiftBy"></param>
/// <param name="startIdx"></param>
/// <param name="length"></param>
public static void Copy(this float[] fromBuffer, float[] toBuffer, int fromStart, int toStart, int length)
{
if (toBuffer == null || fromBuffer.Length == 0 || toBuffer.Length == 0)
return;
int fromBegIdx = fromStart;
int fromEndIdx = fromStart + length;
int toBegIdx = toStart;
int toEndIdx = toStart + length;
if (fromBegIdx < 0)
{
toBegIdx -= fromBegIdx;
fromBegIdx = 0;
}
if (toBegIdx < 0)
{
fromBegIdx -= toBegIdx;
toBegIdx = 0;
}
if (fromEndIdx >= fromBuffer.Length)
{
toEndIdx -= fromEndIdx - fromBuffer.Length + 1;
fromEndIdx = fromBuffer.Length - 1;
}
if (toEndIdx >= toBuffer.Length)
{
fromEndIdx -= toEndIdx - toBuffer.Length + 1;
toEndIdx = fromBuffer.Length - 1;
}
if (fromBegIdx < toBegIdx)
{
// Shift right, so start at the right
for (int fromIdx = fromEndIdx, toIdx = toEndIdx; fromIdx >= fromBegIdx; fromIdx--, toIdx--)
toBuffer[toIdx] = fromBuffer[fromIdx];
}
else
{
// Shift left, so start at the left
for (int fromIdx = fromBegIdx, toIdx = toBegIdx; fromIdx <= fromEndIdx; fromIdx++, toIdx++)
toBuffer[toIdx] = fromBuffer[fromIdx];
}
}
/// <summary>
///
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="buffer"></param>
public static void Clear(this float[] buffer, int startIdx, int endIdx)
{
Array.Clear(buffer, startIdx, endIdx - startIdx + 1);
}
/// <summary>
/// Fill the buffer with the specified value
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="buffer"></param>
/// <param name="?"></param>
public static void Fill(this double[] buffer, double value)
{
for (int idx = 0; idx < buffer.Length; idx++)
buffer[idx] = value;
}
}
}
@@ -1,613 +0,0 @@
using System;
namespace Vocaluxe.Lib.Sound.Record.PitchTracker.Pitch
{
/// <summary>
/// Infinite impulse response filter (old style analog filters)
/// </summary>
class IIRFilter
{
/// <summary>
/// The type of filter
/// </summary>
public enum FilterType
{
None = 0,
LP,
HP,
BP
}
/// <summary>
/// The filter prototype
/// </summary>
public enum ProtoType
{
None = 0,
Butterworth,
Chebyshev,
}
const int kHistMask = 31;
const int kHistSize = 32;
private int m_order;
private ProtoType m_protoType;
private FilterType m_filterType;
private float m_fp1;
private float m_fp2;
private float m_fN;
private float m_ripple;
private float m_sampleRate;
private double[] m_real;
private double[] m_imag;
private double[] m_z;
private double[] m_aCoeff;
private double[] m_bCoeff;
private double[] m_inHistory;
private double[] m_outHistory;
private int m_histIdx;
private bool m_invertDenormal;
public IIRFilter()
{
}
/// <summary>
/// Returns true if all the filter parameters are valid
/// </summary>
public bool FilterValid
{
get
{
if (m_order < 1 || m_order > 16 ||
m_protoType == ProtoType.None ||
m_filterType == FilterType.None ||
m_sampleRate <= 0.0f ||
m_fN <= 0.0f)
return false;
switch (m_filterType)
{
case FilterType.LP:
if (m_fp2 <= 0.0f)
return false;
break;
case FilterType.BP:
if (m_fp1 <= 0.0f || m_fp2 <= 0.0f || m_fp1 >= m_fp2)
return false;
break;
case FilterType.HP:
if (m_fp1 <= 0.0f)
return false;
break;
}
// For bandpass, the order must be even
if (m_filterType == FilterType.BP && (m_order & 1) != 0)
return false;
return true;
}
}
/// <summary>
/// Set the filter prototype
/// </summary>
public ProtoType Proto
{
get { return m_protoType; }
set
{
m_protoType = value;
Design();
}
}
/// <summary>
/// Set the filter type
/// </summary>
public FilterType Type
{
get { return m_filterType; }
set
{
m_filterType = value;
Design();
}
}
public int Order
{
get { return m_order; }
set
{
m_order = Math.Min(16, Math.Max(1, Math.Abs(value)));
if (m_filterType == FilterType.BP && Odd(m_order))
m_order++;
Design();
}
}
public float SampleRate
{
get { return m_sampleRate; }
set
{
m_sampleRate = value;
m_fN = 0.5f * m_sampleRate;
Design();
}
}
public float FreqLow
{
get { return m_fp1; }
set
{
m_fp1 = value;
Design();
}
}
public float FreqHigh
{
get { return m_fp2; }
set
{
m_fp2 = value;
Design();
}
}
public float Ripple
{
get { return m_ripple; }
set
{
m_ripple = value;
Design();
}
}
/// <summary>
/// Returns true if n is odd
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
private bool Odd(int n)
{
return (n & 1) == 1;
}
/// <summary>
/// Square
/// </summary>
/// <param name="f"></param>
/// <returns></returns>
private float Sqr(float value)
{
return value * value;
}
/// <summary>
/// Square
/// </summary>
/// <param name="f"></param>
/// <returns></returns>
private double Sqr(double value)
{
return value * value;
}
/// <summary>
/// Determines poles and zeros of IIR filter
/// based on bilinear transform method
/// </summary>
private void LocatePolesAndZeros()
{
m_real = new double[m_order + 1];
m_imag = new double[m_order + 1];
m_z = new double[m_order + 1];
double ln10 = Math.Log(10.0);
// Butterworth, Chebyshev parameters
int n = m_order;
if (m_filterType == FilterType.BP)
n = n / 2;
int ir = n % 2;
int n1 = n + ir;
int n2 = (3 * n + ir) / 2 - 1;
double f1;
switch (m_filterType)
{
case FilterType.LP:
f1 = m_fp2;
break;
case FilterType.HP:
f1 = m_fN - m_fp1;
break;
case FilterType.BP:
f1 = m_fp2 - m_fp1;
break;
default:
f1 = 0.0;
break;
}
double tanw1 = Math.Tan(0.5 * Math.PI * f1 / m_fN);
double tansqw1 = Sqr(tanw1);
// Real and Imaginary parts of low-pass poles
double t, a = 1.0, r = 1.0, i = 1.0;
for (int k = n1; k <= n2; k++)
{
t = 0.5 * (2 * k + 1 - ir) * Math.PI / (double)n;
switch (m_protoType)
{
case ProtoType.Butterworth:
double b3 = 1.0 - 2.0 * tanw1 * Math.Cos(t) + tansqw1;
r = (1.0 - tansqw1) / b3;
i = 2.0 * tanw1 * Math.Sin(t) / b3;
break;
case ProtoType.Chebyshev:
double d = 1.0 - Math.Exp(-0.05 * m_ripple * ln10);
double e = 1.0 / Math.Sqrt(1.0 / Sqr(1.0 - d) - 1.0);
double x = Math.Pow(Math.Sqrt(e * e + 1.0) + e, 1.0 / (double)n);
a = 0.5 * (x - 1.0 / x);
double b = 0.5 * (x + 1.0 / x);
double c3 = a * tanw1 * Math.Cos(t);
double c4 = b * tanw1 * Math.Sin(t);
double c5 = Sqr(1.0 - c3) + Sqr(c4);
r = 2.0 * (1.0 - c3) / c5 - 1.0;
i = 2.0 * c4 / c5;
break;
}
int m = 2 * (n2 - k) + 1;
m_real[m + ir] = r;
m_imag[m + ir] = Math.Abs(i);
m_real[m + ir + 1] = r;
m_imag[m + ir + 1] = -Math.Abs(i);
}
if (Odd(n))
{
if (m_protoType == ProtoType.Butterworth)
r = (1.0 - tansqw1) / (1.0 + 2.0 * tanw1 + tansqw1);
if (m_protoType == ProtoType.Chebyshev)
r = 2.0 / (1.0 + a * tanw1) - 1.0;
m_real[1] = r;
m_imag[1] = 0.0;
}
switch (m_filterType)
{
case FilterType.LP:
for (int m = 1; m <= n; m++)
m_z[m] = -1.0;
break;
case FilterType.HP:
// Low-pass to high-pass transformation
for (int m = 1; m <= n; m++)
{
m_real[m] = -m_real[m];
m_z[m] = 1.0;
}
break;
case FilterType.BP:
// Low-pass to bandpass transformation
for (int m = 1; m <= n; m++)
{
m_z[m] = 1.0;
m_z[m + n] = -1.0;
}
double f4 = 0.5 * Math.PI * m_fp1 / m_fN;
double f5 = 0.5 * Math.PI * m_fp2 / m_fN;
double aa = Math.Cos(f4 + f5) / Math.Cos(f5 - f4);
double aR, aI, h1, h2, p1R, p2R, p1I, p2I;
for (int m1 = 0; m1 <= (m_order - 1) / 2; m1++)
{
int m = 1 + 2 * m1;
aR = m_real[m];
aI = m_imag[m];
if (Math.Abs(aI) < 0.0001)
{
h1 = 0.5 * aa * (1.0 + aR);
h2 = Sqr(h1) - aR;
if (h2 > 0.0)
{
p1R = h1 + Math.Sqrt(h2);
p2R = h1 - Math.Sqrt(h2);
p1I = 0.0;
p2I = 0.0;
}
else
{
p1R = h1;
p2R = h1;
p1I = Math.Sqrt(Math.Abs(h2));
p2I = -p1I;
}
}
else
{
double fR = aa * 0.5 * (1.0 + aR);
double fI = aa * 0.5 * aI;
double gR = Sqr(fR) - Sqr(fI) - aR;
double gI = 2 * fR * fI - aI;
double sR = Math.Sqrt(0.5 * Math.Abs(gR + Math.Sqrt(Sqr(gR) + Sqr(gI))));
double sI = gI / (2.0 * sR);
p1R = fR + sR;
p1I = fI + sI;
p2R = fR - sR;
p2I = fI - sI;
}
m_real[m] = p1R;
m_real[m + 1] = p2R;
m_imag[m] = p1I;
m_imag[m + 1] = p2I;
}
if (Odd(n))
{
m_real[2] = m_real[n + 1];
m_imag[2] = m_imag[n + 1];
}
for (int k = n; k >= 1; k--)
{
int m = 2 * k - 1;
m_real[m] = m_real[k];
m_real[m + 1] = m_real[k];
m_imag[m] = Math.Abs(m_imag[k]);
m_imag[m + 1] = -Math.Abs(m_imag[k]);
}
break;
}
}
/// <summary>
/// Calculate all the values
/// </summary>
public void Design()
{
if (!this.FilterValid)
return;
m_aCoeff = new double[m_order + 1];
m_bCoeff = new double[m_order + 1];
m_inHistory = new double[kHistSize];
m_outHistory = new double[kHistSize];
double[] newA = new double[m_order + 1];
double[] newB = new double[m_order + 1];
// Find filter poles and zeros
LocatePolesAndZeros();
// Compute filter coefficients from pole/zero values
m_aCoeff[0] = 1.0;
m_bCoeff[0] = 1.0;
for (int i = 1; i <= m_order; i++)
{
m_aCoeff[i] = 0.0;
m_bCoeff[i] = 0.0;
}
int k = 0;
int n = m_order;
int pairs = n / 2;
if (Odd(m_order))
{
// First subfilter is first order
m_aCoeff[1] = -m_z[1];
m_bCoeff[1] = -m_real[1];
k = 1;
}
for (int p = 1; p <= pairs; p++)
{
int m = 2 * p - 1 + k;
double alpha1 = -(m_z[m] + m_z[m + 1]);
double alpha2 = m_z[m] * m_z[m + 1];
double beta1 = -2.0 * m_real[m];
double beta2 = Sqr(m_real[m]) + Sqr(m_imag[m]);
newA[1] = m_aCoeff[1] + alpha1 * m_aCoeff[0];
newB[1] = m_bCoeff[1] + beta1 * m_bCoeff[0];
for (int i = 2; i <= n; i++)
{
newA[i] = m_aCoeff[i] + alpha1 * m_aCoeff[i - 1] + alpha2 * m_aCoeff[i - 2];
newB[i] = m_bCoeff[i] + beta1 * m_bCoeff[i - 1] + beta2 * m_bCoeff[i - 2];
}
for (int i = 1; i <= n; i++)
{
m_aCoeff[i] = newA[i];
m_bCoeff[i] = newB[i];
}
}
// Ensure the filter is normalized
FilterGain(1000);
}
/// <summary>
/// Reset the history buffers
/// </summary>
public void Reset()
{
if (m_inHistory != null)
m_inHistory.Clear();
if (m_outHistory != null)
m_outHistory.Clear();
m_histIdx = 0;
}
/// <summary>
/// Reset the filter, and fill the appropriate history buffers with the specified value
/// </summary>
/// <param name="historyValue"></param>
public void Reset(double startValue)
{
m_histIdx = 0;
if (m_inHistory == null || m_outHistory == null)
return;
m_inHistory.Fill(startValue);
if (m_inHistory != null)
{
switch (m_filterType)
{
case FilterType.LP:
m_outHistory.Fill(startValue);
break;
default:
m_outHistory.Clear();
break;
}
}
}
/// <summary>
/// Apply the filter to the buffer
/// </summary>
/// <param name="bufIn"></param>
public void FilterBuffer(float[] srcBuf, long srcPos, float[] dstBuf, long dstPos, long nLen)
{
const double kDenormal = 0.000000000000001;
double denormal = m_invertDenormal ? -kDenormal : kDenormal;
m_invertDenormal = !m_invertDenormal;
for (int sampleIdx = 0; sampleIdx < nLen; sampleIdx++)
{
double sum = 0.0f;
m_inHistory[m_histIdx] = srcBuf[srcPos + sampleIdx] + denormal;
for (int idx = 0; idx < m_aCoeff.Length; idx++)
sum += m_aCoeff[idx] * m_inHistory[(m_histIdx - idx) & kHistMask];
for (int idx = 1; idx < m_bCoeff.Length; idx++)
sum -= m_bCoeff[idx] * m_outHistory[(m_histIdx - idx) & kHistMask];
m_outHistory[m_histIdx] = sum;
m_histIdx = (m_histIdx + 1) & kHistMask;
dstBuf[dstPos + sampleIdx] = (float)sum;
}
}
public float FilterSample(float inVal)
{
double sum = 0.0f;
m_inHistory[m_histIdx] = inVal;
for (int idx = 0; idx < m_aCoeff.Length; idx++)
sum += m_aCoeff[idx] * m_inHistory[(m_histIdx - idx) & kHistMask];
for (int idx = 1; idx < m_bCoeff.Length; idx++)
sum -= m_bCoeff[idx] * m_outHistory[(m_histIdx - idx) & kHistMask];
m_outHistory[m_histIdx] = sum;
m_histIdx = (m_histIdx + 1) & kHistMask;
return (float)sum;
}
/// <summary>
/// Get the gain at the specified number of frequency points
/// </summary>
/// <param name="freqPoints"></param>
/// <returns></returns>
public float[] FilterGain(int freqPoints)
{
// Filter gain at uniform frequency intervals
float[] g = new float[freqPoints];
double theta, s, c, sac, sas, sbc, sbs;
float gMax = -100.0f;
float sc = 10.0f / (float)Math.Log(10.0f);
double t = Math.PI / (freqPoints - 1);
for (int i = 0; i < freqPoints; i++)
{
theta = i * t;
if (i == 0)
theta = Math.PI * 0.0001;
if (i == freqPoints - 1)
theta = Math.PI * 0.9999;
sac = 0.0f;
sas = 0.0f;
sbc = 0.0f;
sbs = 0.0f;
for (int k = 0; k <= m_order; k++)
{
c = Math.Cos(k * theta);
s = Math.Sin(k * theta);
sac += c * m_aCoeff[k];
sas += s * m_aCoeff[k];
sbc += c * m_bCoeff[k];
sbs += s * m_bCoeff[k];
}
g[i] = sc * (float)Math.Log((Sqr(sac) + Sqr(sas)) / (Sqr(sbc) + Sqr(sbs)));
gMax = Math.Max(gMax, g[i]);
}
// Normalize to 0 dB maximum gain
for (int i = 0; i < freqPoints; i++)
g[i] -= gMax;
// Normalize numerator (a) coefficients
float normFactor = (float)Math.Pow(10.0, -0.05 * gMax);
for (int i = 0; i <= m_order; i++)
m_aCoeff[i] *= normFactor;
return g;
}
}
}
@@ -1,561 +0,0 @@
using System;
namespace Vocaluxe.Lib.Sound.Record.PitchTracker.Pitch
{
/// <summary>
/// Pitch related DSP
/// </summary>
public class PitchDsp
{
public static readonly double InverseLog2 = 1.0 / Math.Log10(2.0);
private const int kCourseOctaveSteps = 96;
private const int kScanHiSize = 31;
private const float kScanHiFreqStep = 1.005f;
private const int kMinMidiNote = 21; // A0
private const int kMaxMidiNote = 108; // C8
private float m_minPitch;
private float m_maxPitch;
private int m_minNote;
private int m_maxNote;
private int m_blockLen14; // 1/4 block len
private int m_blockLen24; // 2/4 block len
private int m_blockLen34; // 3/4 block len
private int m_blockLen44; // 4/4 block len
private double m_sampleRate;
private int m_numCourseSteps;
private float[] m_pCourseFreqOffset;
private float[] m_pCourseFreq;
private float[] m_scanHiOffset = new float[kScanHiSize];
private float[] m_peakBuf = new float[kScanHiSize];
private int m_prevPitchIdx;
private float[] m_detectCurve;
/// <summary>
/// Constructor
/// </summary>
/// <param name="fSampleRate"></param>
/// <param name="minFreq"></param>
/// <param name="maxFreq"></param>
/// <param name="fFreqStep"></param>
public PitchDsp(double sampleRate, float minPitch, float maxPitch)
{
m_sampleRate = sampleRate;
m_minPitch = minPitch;
m_maxPitch = maxPitch;
m_minNote = (int)(PitchToMidiNote(m_minPitch) + 0.5f) + 2;
m_maxNote = (int)(PitchToMidiNote(m_maxPitch) + 0.5f) - 2;
m_blockLen44 = (int)(m_sampleRate / m_minPitch + 0.5f);
m_blockLen34 = (m_blockLen44 * 3) / 4;
m_blockLen24 = m_blockLen44 / 2;
m_blockLen14 = m_blockLen44 / 4;
m_numCourseSteps = (int)((Math.Log((double)m_maxPitch / (double)m_minPitch) / Math.Log(2.0)) * kCourseOctaveSteps + 0.5) + 3;
m_pCourseFreqOffset = new float[m_numCourseSteps + 10000];
m_pCourseFreq = new float[m_numCourseSteps + 10000];
m_detectCurve = new float[m_numCourseSteps];
double freqStep = 1.0 / Math.Pow(2.0, 1.0 / kCourseOctaveSteps);
double curFreq = m_maxPitch / freqStep;
// frequency is stored from high to low
for (int idx = 0; idx < m_numCourseSteps; idx++)
{
m_pCourseFreq[idx] = (float)curFreq;
m_pCourseFreqOffset[idx] = (float)(m_sampleRate / curFreq);
curFreq *= freqStep;
}
for (int idx = 0; idx < kScanHiSize; idx++)
m_scanHiOffset[idx] = (float)Math.Pow(kScanHiFreqStep, (kScanHiSize / 2) - idx);
}
/// <summary>
/// Get the max detected pitch
/// </summary>
public float MaxPitch
{
get { return m_maxPitch; }
}
/// <summary>
/// Get the min detected pitch
/// </summary>
public float MinPitch
{
get { return m_minPitch; }
}
/// <summary>
/// Get the max note
/// </summary>
public int MaxNote
{
get { return m_maxNote; }
}
/// <summary>
/// Get the min note
/// </summary>
public int MinNote
{
get { return m_minNote; }
}
/// <summary>
/// Detect the pitch
/// </summary>
public float DetectPitch(float[] samplesLo, float[] samplesHi)
{
return DetectPitchLo(samplesLo, samplesHi);
}
/// <summary>
/// Low resolution pitch detection
/// </summary>
/// <param name="dataIdx"></param>
/// <param name="begFreqIdx"></param>
/// <param name="endFreqIdx"></param>
/// <param name="blockLen"></param>
/// <param name="stepSize"></param>
/// <returns></returns>
private float DetectPitchLo(float[] samplesLo, float[] samplesHi)
{
m_detectCurve.Clear();
const int skipSize = 8;
const int peakScanSize = 23;
const int peakScanSizeHalf = peakScanSize / 2;
float peakThresh1 = 200.0f;
float peakThresh2 = 600.0f;
bool bufferSwitched = false;
for (int idx = 0; idx < m_numCourseSteps; idx += skipSize)
{
int blockLen = Math.Min(m_blockLen44, (int)m_pCourseFreqOffset[idx] * 2);
float[] curSamples = null;
// 258 is at 250 Hz, which is the switchover frequency for the two filters
bool loBuffer = idx >= 258;
if (loBuffer)
{
if (!bufferSwitched)
{
m_detectCurve.Clear(258 - peakScanSizeHalf, 258 + peakScanSizeHalf);
bufferSwitched = true;
}
curSamples = samplesLo;
}
else
curSamples = samplesHi;
int stepSizeLoRes = blockLen / 10;
int stepSizeHiRes = Math.Max(1, Math.Min(5, idx * 5 / m_numCourseSteps));
float fValue = RatioAbsDiffLinear(curSamples, idx, blockLen, stepSizeLoRes, false);
if (fValue > peakThresh1)
{
// Do a closer search for the peak
int peakIdx = -1;
float peakVal = 0.0f;
float prevVal = 0.0f;
int dir = 4; // start going forward
int curPos = idx; // start at center of the scan range
int begSearch = Math.Max(idx - peakScanSizeHalf, 0);
int endSearch = Math.Min(idx + peakScanSizeHalf, m_numCourseSteps - 1);
while (curPos >= begSearch && curPos < endSearch)
{
float curVal = RatioAbsDiffLinear(curSamples, curPos, blockLen, stepSizeHiRes, true);
if (peakVal < curVal)
{
peakVal = curVal;
peakIdx = curPos;
}
if (prevVal > curVal)
{
dir = -dir >> 1;
if (dir == 0)
{
if (peakVal > peakThresh2 && peakIdx >= 6 && peakIdx <= m_numCourseSteps - 7)
{
float fValL = RatioAbsDiffLinear(curSamples, peakIdx - 5, blockLen, stepSizeHiRes, true);
float fValR = RatioAbsDiffLinear(curSamples, peakIdx + 5, blockLen, stepSizeHiRes, true);
float fPointy = peakVal / (fValL + fValR) * 2.0f;
float minPointy = (m_prevPitchIdx > 0 && Math.Abs(m_prevPitchIdx - peakIdx) < 10) ? 1.2f : 1.5f;
if (fPointy > minPointy)
{
float pitchHi = DetectPitchHi(curSamples, peakIdx);
if (pitchHi > 1.0f)
{
m_prevPitchIdx = peakIdx;
return pitchHi;
}
}
}
break;
}
}
prevVal = curVal;
curPos += dir;
}
}
}
m_prevPitchIdx = 0;
return 0.0f;
}
/// <summary>
/// High resolution pitch detection
/// </summary>
/// <param name="dataIdx"></param>
/// <param name="lowFreqIdx"></param>
/// <returns></returns>
private float DetectPitchHi(float[] samples, int lowFreqIdx)
{
int peakIdx = -1;
float prevVal = 0.0f;
int dir = 4; // start going forward
int curPos = kScanHiSize >> 1; // start at center of the scan range
m_peakBuf.Clear();
float offset = m_pCourseFreqOffset[lowFreqIdx];
while (curPos >= 0 && curPos < kScanHiSize)
{
if (m_peakBuf[curPos] == 0.0f)
m_peakBuf[curPos] = SumAbsDiffHermite(samples, offset * m_scanHiOffset[curPos], m_blockLen44, 1);
if (peakIdx < 0 || m_peakBuf[peakIdx] < m_peakBuf[curPos])
peakIdx = curPos;
if (prevVal > m_peakBuf[curPos])
{
dir = -dir >> 1;
if (dir == 0)
{
// found the peak
float minVal = Math.Min(m_peakBuf[peakIdx - 1], m_peakBuf[peakIdx + 1]);
minVal -= minVal * (1.0f / 32.0f);
var y1 = (float)Math.Log10(m_peakBuf[peakIdx - 1] - minVal);
var y2 = (float)Math.Log10(m_peakBuf[peakIdx] - minVal);
var y3 = (float)Math.Log10(m_peakBuf[peakIdx + 1] - minVal);
float fIdx = (float)peakIdx + (y3 - y1) / (2.0f * (2.0f * y2 - y1 - y3));
return (float)Math.Pow(kScanHiFreqStep, fIdx - (kScanHiSize / 2)) * m_pCourseFreq[lowFreqIdx];
}
}
prevVal = m_peakBuf[curPos];
curPos += dir;
}
return 0.0f;
}
/// <summary>
/// Create a sine wave with the specified frequency, amplitude and starting angle.
/// Returns the updated angle.
/// </summary>
/// <param name="buffer"></param>
/// <param name="numSamples"></param>
/// <param name="freq"></param>
/// <param name="amplitude"></param>
/// <param name="startAngle"></param>
/// <returns></returns>
public static double CreateSineWave(float[] buffer, int numSamples, float sampleRate,
float freq, float amplitude, double startAngle)
{
double angleStep = freq / sampleRate * Math.PI * 2.0;
double curAngle = startAngle;
for (int idx = 0; idx < numSamples; idx++)
{
buffer[idx] = (float)Math.Sin(curAngle) * amplitude;
curAngle += angleStep;
while (curAngle > Math.PI)
curAngle -= Math.PI * 2.0;
}
return curAngle;
}
/// <summary>
/// Returns true if the level is above the specified value
/// </summary>
/// <param name="buffer"></param>
/// <param name="startIdx"></param>
/// <param name="len"></param>
/// <param name="level"></param>
/// <returns></returns>
public bool LevelIsAbove(float[] buffer, int len, float level)
{
if (buffer == null || buffer.Length == 0)
return false;
int endIdx = Math.Min(buffer.Length, len);
for (int idx = 0; idx < endIdx; idx++)
{
if (Math.Abs(buffer[idx]) >= level)
return true;
}
return false;
}
/// <summary>
/// Copy the data from the source to the destination buffer
/// </summary>
/// <param name="source"></param>
/// <param name="destination"></param>
/// <param name="startPos"></param>
/// <param name="length"></param>
public static void CopyBuffer<T>(T[] source, int srcStart, T[] destination, int dstStart, int length)
{
if (length < 0)
throw new ArgumentOutOfRangeException("length");
if (source == null || source.Length < srcStart + length)
throw new Exception("Source buffer is null or not large enough");
if (destination == null || destination.Length < dstStart + length)
throw new Exception("Destination buffer is null or not large enough");
int srcIdx = srcStart;
int dstIdx = dstStart;
for (int idx = 0; idx < length; idx++)
destination[dstIdx++] = source[srcIdx++];
}
/// <summary>
/// // 4-point, 3rd-order Hermite (x-form)
/// </summary>
private float InterpolateHermite(float fY0, float fY1, float fY2, float fY3, float frac)
{
float c1 = 0.5f * (fY2 - fY0);
float c3 = 1.5f * (fY1 - fY2) + 0.5f * (fY3 - fY0);
float c2 = fY0 - fY1 + c1 - c3;
return ((c3 * frac + c2) * frac + c1) * frac + fY1;
}
/// <summary>
/// Linear interpolation
/// nFrac is based on 1.0 = 256
/// </summary>
private float InterpolateLinear(float y0, float y1, float frac)
{
return y0 * (1.0f - frac) + y1 * frac;
}
/// <summary>
/// Medium Low res SumAbsDiff
/// </summary>
private float RatioAbsDiffLinear(float[] samples, int freqIdx, int blockLen, int stepSize, bool hiRes)
{
if (hiRes && m_detectCurve[freqIdx] > 0.0f)
return m_detectCurve[freqIdx];
var offsetInt = (int)m_pCourseFreqOffset[freqIdx];
float offsetFrac = m_pCourseFreqOffset[freqIdx] - offsetInt;
float rect = 0.0f;
float absDiff = 0.01f; // prevent divide by zero
int count = 0;
float interp;
float sample;
// Do a scan using linear interpolation and the specified step size
for (int idx = 0; idx < blockLen; idx += stepSize, count++)
{
sample = samples[idx];
interp = InterpolateLinear(samples[offsetInt + idx], samples[offsetInt + idx + 1], offsetFrac);
absDiff += Math.Abs(sample - interp);
rect += Math.Abs(sample) + Math.Abs(interp);
}
float finalVal = rect / absDiff * 100.0f;
if (hiRes)
m_detectCurve[freqIdx] = finalVal;
return finalVal;
}
/// <summary>
/// Medium High res SumAbsDiff
/// </summary>
private float SumAbsDiffHermite(float[] samples, float fOffset, int blockLen, int stepSize)
{
var offsetInt = (int)fOffset;
float offsetFrac = fOffset - offsetInt;
float value = 0.001f; // prevent divide by zero
int count = 0;
// do a scan using linear interpolation and the specified step size
for (int idx = 0; idx < blockLen; idx += stepSize, count++)
{
int offsetIdx = offsetInt + idx;
value += Math.Abs(samples[idx] - InterpolateHermite(samples[offsetIdx - 1],
samples[offsetIdx],
samples[offsetIdx + 1],
samples[offsetIdx + 2],
offsetFrac));
}
return count / value;
}
/// <summary>
/// Get the MIDI note and cents of the pitch
/// </summary>
/// <param name="pitch"></param>
/// <param name="note"></param>
/// <param name="cents"></param>
/// <returns></returns>
public static bool PitchToMidiNote(float pitch, out int note, out int cents)
{
if (pitch < 20.0f)
{
note = 0;
cents = 0;
return false;
}
float fNote = (float)((12.0 * Math.Log10(pitch / 55.0) * InverseLog2)) + 33.0f;
note = (int)(fNote + 0.5f);
cents = (int)((note - fNote) * 100);
return true;
}
/// <summary>
/// Get the pitch from the MIDI note
/// </summary>
/// <param name="pitch"></param>
/// <returns></returns>
public static float PitchToMidiNote(float pitch)
{
if (pitch < 20.0f)
return 0.0f;
return (float)(12.0 * Math.Log10(pitch / 55.0) * InverseLog2) + 33.0f;
}
/// <summary>
/// Get the pitch from the MIDI note
/// </summary>
/// <param name="note"></param>
/// <returns></returns>
public float MidiNoteToPitch(float note)
{
if (note < 33.0f)
return 0.0f;
float pitch = (float)Math.Pow(10.0, (note - 33.0f) / InverseLog2 / 12.0f) * 55.0f;
return pitch <= m_maxPitch ? pitch : 0.0f;
}
/// <summary>
/// Format a midi note to text
/// </summary>
/// <param name="note"></param>
/// <param name="sharps"></param>
/// <param name="showOctave"></param>
/// <returns></returns>
public static string GetNoteName(int note, bool sharps, bool showOctave)
{
if (note < kMinMidiNote || note > kMaxMidiNote)
return null;
note -= kMinMidiNote;
int octave = (note + 9) / 12;
note = note % 12;
string noteText = null;
switch (note)
{
case 0:
noteText = "A";
break;
case 1:
noteText = sharps ? "A#" : "Bb";
break;
case 2:
noteText = "B";
break;
case 3:
noteText = "C";
break;
case 4:
noteText = sharps ? "C#" : "Db";
break;
case 5:
noteText = "D";
break;
case 6:
noteText = sharps ? "D#" : "Eb";
break;
case 7:
noteText = "E";
break;
case 8:
noteText = "F";
break;
case 9:
noteText = sharps ? "F#" : "Gb";
break;
case 10:
noteText = "G";
break;
case 11:
noteText = sharps ? "G#" : "Ab";
break;
}
if (showOctave)
noteText += " " + octave.ToString();
return noteText;
}
}
}
@@ -1,431 +0,0 @@
using System;
using System.Collections.Generic;
using System.Collections;
namespace Vocaluxe.Lib.Sound.Record.PitchTracker.Pitch
{
/// <summary>
/// Tracks pitch
/// </summary>
// ReSharper disable InconsistentNaming
public class PitchTracker
{
private const int kOctaveSteps = 96;
private const int kStepOverlap = 4;
private const float kMinFreq = 50.0f; // A1, Midi note 33, 55.0Hz
private const float kMaxFreq = 1800.0f; // A#6. Midi note 92
private const int kStartCircular = 40; // how far into the sample buffer do we start checking (allow for filter settling)
private const float kDetectOverlapSec = 0.005f;
private const float kMaxOctaveSecRate = 10.0f;
private const float kAvgOffset = 0.005f; // time offset between pitch averaging values
private const int kAvgCount = 1; // number of average pitch samples to take
private const float kCircularBufSaveTime = 1.0f; // Amount of samples to store in the history buffer
private PitchDsp m_dsp;
private CircularBuffer<float> m_circularBufferLo;
private CircularBuffer<float> m_circularBufferHi;
private double m_sampleRate;
private float m_detectLevelThreshold = 0.01f; // -40dB
private int m_pitchRecordsPerSecond = 50; // default is 50, or one record every 20ms
private float[] m_pitchBufLo;
private float[] m_pitchBufHi;
private int m_pitchBufSize;
private int m_samplesPerPitchBlock;
private int m_curPitchIndex;
private long m_curPitchSamplePos;
private int m_detectOverlapSamples;
private float m_maxOverlapDiff;
private bool m_recordPitchRecords;
private int m_pitchRecordHistorySize;
private List<PitchRecord> m_pitchRecords = new List<PitchRecord>();
private PitchRecord m_curPitchRecord = new PitchRecord();
private IIRFilter m_iirFilterLoLo;
private IIRFilter m_iirFilterLoHi;
private IIRFilter m_iirFilterHiLo;
private IIRFilter m_iirFilterHiHi;
public float LastMaxVol = 0;
public delegate void PitchDetectedHandler(PitchTracker sender, PitchRecord pitchRecord);
public event PitchDetectedHandler PitchDetected;
/// <summary>
/// Constructor
/// </summary>
public PitchTracker() {}
/// <summary>
/// Set the sample rate
/// </summary>
public double SampleRate
{
set
{
if (m_sampleRate == value)
return;
m_sampleRate = value;
Setup();
}
}
/// <summary>
/// Set the detect level threshold, The value must be between 0.0001f and 1.0f (-80 dB to 0 dB)
/// </summary>
public float DetectLevelThreshold
{
set
{
float newValue = Math.Max(0.0001f, Math.Min(1.0f, value));
if (m_detectLevelThreshold == newValue)
return;
m_detectLevelThreshold = newValue;
//Setup();
}
get { return m_detectLevelThreshold; }
}
/// <summary>
/// Return the samples per pitch block
/// </summary>
public int SamplesPerPitchBlock
{
get { return m_samplesPerPitchBlock; }
}
/// <summary>
/// Get or set the number of pitch records per second (default is 50, or one record every 20ms)
/// </summary>
public int PitchRecordsPerSecond
{
get { return m_pitchRecordsPerSecond; }
set
{
m_pitchRecordsPerSecond = Math.Max(1, Math.Min(100, value));
Setup();
}
}
/// <summary>
/// Get or set whether pitch records should be recorded into a history buffer
/// </summary>
public bool RecordPitchRecords
{
get { return m_recordPitchRecords; }
set
{
if (m_recordPitchRecords == value)
return;
m_recordPitchRecords = value;
if (!m_recordPitchRecords)
m_pitchRecords = new List<PitchRecord>();
}
}
/// <summary>
/// Get or set the max number of pitch records to keep. A value of 0 means no limit.
/// Don't leave this at 0 when RecordPitchRecords is true and this is used in a realtime
/// application since the buffer will grow indefinately!
/// </summary>
public int PitchRecordHistorySize
{
get { return m_pitchRecordHistorySize; }
set
{
m_pitchRecordHistorySize = value;
m_pitchRecords.Capacity = m_pitchRecordHistorySize;
}
}
/// <summary>
/// Get the current pitch records
/// </summary>
public IList PitchRecords
{
get { return m_pitchRecords.AsReadOnly(); }
}
/// <summary>
/// Get the latest pitch record
/// </summary>
public PitchRecord CurrentPitchRecord
{
get { return m_curPitchRecord; }
}
/// <summary>
/// Get the current pitch position
/// </summary>
public long CurrentPitchSamplePosition
{
get { return m_curPitchSamplePos; }
}
/// <summary>
/// Get the minimum frequency that can be detected
/// </summary>
public static float MinDetectFrequency
{
get { return kMinFreq; }
}
/// <summary>
/// Get the maximum frequency that can be detected
/// </summary>
public static float MaxDetectFrequency
{
get { return kMaxFreq; }
}
/// <summary>
/// Get the frequency step
/// </summary>
public static double FrequencyStep
{
get { return Math.Pow(2.0, 1.0 / kOctaveSteps); }
}
/// <summary>
/// Get the number of samples that the detected pitch is offset from the input buffer.
/// This is just an estimate to sync up the samples and detected pitch
/// </summary>
public int DetectSampleOffset
{
get { return (m_pitchBufSize + m_detectOverlapSamples) / 2; }
}
/// <summary>
/// Reset the pitch tracker. Call this when the sample position is
/// not consecutive from the previous position
/// </summary>
public void Reset()
{
m_curPitchIndex = 0;
m_curPitchSamplePos = 0;
m_pitchRecords.Clear();
m_iirFilterLoLo.Reset();
m_iirFilterLoHi.Reset();
m_iirFilterHiLo.Reset();
m_iirFilterHiHi.Reset();
m_circularBufferLo.Reset();
m_circularBufferLo.Clear();
m_circularBufferHi.Reset();
m_circularBufferHi.Clear();
m_pitchBufLo.Clear();
m_pitchBufHi.Clear();
m_circularBufferLo.StartPosition = -m_detectOverlapSamples;
m_circularBufferLo.Available = m_detectOverlapSamples;
m_circularBufferHi.StartPosition = -m_detectOverlapSamples;
m_circularBufferHi.Available = m_detectOverlapSamples;
}
/// <summary>
/// Process the passed in buffer of data. During this call, the PitchDetected event will
/// be fired zero or more times, depending how many pitch records will fit in the new
/// and previously cached buffer.
///
/// This means that there is no size restriction on the buffer that is passed into ProcessBuffer.
/// For instance, ProcessBuffer can be called with one very large buffer that contains all of the
/// audio to be processed (many PitchDetected events will be fired), or just a small buffer at
/// a time which is more typical for realtime applications. In the latter case, the PitchDetected
/// event might not be fired at all since additional calls must first be made to accumulate enough
/// data do another pitch detect operation.
/// </summary>
/// <param name="inBuffer">Input buffer. Samples must be in the range -1.0 to 1.0</param>
/// <param name="maxVolume"></param>
/// <param name="sampleCount">Number of samples to process. Zero means all samples in the buffer</param>
public void ProcessBuffer(float[] inBuffer, int sampleCount = 0)
{
if (inBuffer == null)
throw new ArgumentNullException("inBuffer", "Input buffer cannot be null");
int samplesProcessed = 0;
int srcLength = sampleCount == 0 ? inBuffer.Length : Math.Min(sampleCount, inBuffer.Length);
float maxVolume = LastMaxVol * 0.85f;
while (samplesProcessed < srcLength)
{
int frameCount = Math.Min(srcLength - samplesProcessed, m_pitchBufSize + m_detectOverlapSamples);
m_iirFilterLoLo.FilterBuffer(inBuffer, samplesProcessed, m_pitchBufLo, 0, frameCount);
m_iirFilterLoHi.FilterBuffer(m_pitchBufLo, 0, m_pitchBufLo, 0, frameCount);
m_iirFilterHiLo.FilterBuffer(inBuffer, samplesProcessed, m_pitchBufHi, 0, frameCount);
m_iirFilterHiHi.FilterBuffer(m_pitchBufHi, 0, m_pitchBufHi, 0, frameCount);
m_circularBufferLo.WriteBuffer(m_pitchBufLo, frameCount);
m_circularBufferHi.WriteBuffer(m_pitchBufHi, frameCount);
// Loop while there is enough samples in the circular buffer
while (m_circularBufferLo.ReadBuffer(m_pitchBufLo, m_curPitchSamplePos, m_pitchBufSize + m_detectOverlapSamples))
{
float pitch1;
float pitch2;
float detectedPitch = 0.0f;
m_circularBufferHi.ReadBuffer(m_pitchBufHi, m_curPitchSamplePos, m_pitchBufSize + m_detectOverlapSamples);
maxVolume = 0f;
for (int i = 0; i < (m_pitchBufSize + m_detectOverlapSamples) / 2; i++)
{
if (maxVolume < m_pitchBufHi[i])
maxVolume = m_pitchBufHi[i];
if (maxVolume < m_pitchBufLo[i])
maxVolume = m_pitchBufLo[i];
}
pitch1 = (maxVolume >= m_detectLevelThreshold) ? m_dsp.DetectPitch(m_pitchBufLo, m_pitchBufHi) : 0f;
if (pitch1 > 0.0f)
{
// Shift the buffers left by the overlapping amount
m_pitchBufLo.Copy(m_pitchBufLo, m_detectOverlapSamples - 1, 0, m_pitchBufSize);
m_pitchBufHi.Copy(m_pitchBufHi, m_detectOverlapSamples - 1, 0, m_pitchBufSize);
pitch2 = m_dsp.DetectPitch(m_pitchBufLo, m_pitchBufHi);
if (pitch2 > 0.0f)
{
float fDiff = Math.Max(pitch1, pitch2) / Math.Min(pitch1, pitch2) - 1.0f;
if (fDiff < m_maxOverlapDiff)
detectedPitch = (pitch1 + pitch2) * 0.5f;
}
}
// Log the pitch record
AddPitchRecord(detectedPitch);
m_curPitchSamplePos += m_samplesPerPitchBlock;
m_curPitchIndex++;
}
samplesProcessed += frameCount;
}
LastMaxVol = maxVolume;
}
/// <summary>
/// Setup
/// </summary>
private void Setup()
{
if (m_sampleRate < 1.0f)
return;
m_dsp = new PitchDsp(m_sampleRate, kMinFreq, kMaxFreq);
m_iirFilterLoLo = new IIRFilter();
m_iirFilterLoLo.Proto = IIRFilter.ProtoType.Butterworth;
m_iirFilterLoLo.Type = IIRFilter.FilterType.HP;
m_iirFilterLoLo.Order = 5;
m_iirFilterLoLo.FreqLow = 45.0f;
m_iirFilterLoLo.SampleRate = (float)m_sampleRate;
m_iirFilterLoHi = new IIRFilter();
m_iirFilterLoHi.Proto = IIRFilter.ProtoType.Butterworth;
m_iirFilterLoHi.Type = IIRFilter.FilterType.LP;
m_iirFilterLoHi.Order = 5;
m_iirFilterLoHi.FreqHigh = 280.0f;
m_iirFilterLoHi.SampleRate = (float)m_sampleRate;
m_iirFilterHiLo = new IIRFilter();
m_iirFilterHiLo.Proto = IIRFilter.ProtoType.Butterworth;
m_iirFilterHiLo.Type = IIRFilter.FilterType.HP;
m_iirFilterHiLo.Order = 5;
m_iirFilterHiLo.FreqLow = 45.0f;
m_iirFilterHiLo.SampleRate = (float)m_sampleRate;
m_iirFilterHiHi = new IIRFilter();
m_iirFilterHiHi.Proto = IIRFilter.ProtoType.Butterworth;
m_iirFilterHiHi.Type = IIRFilter.FilterType.LP;
m_iirFilterHiHi.Order = 5;
m_iirFilterHiHi.FreqHigh = 2000.0f;
m_iirFilterHiHi.SampleRate = (float)m_sampleRate;
m_detectOverlapSamples = (int)(kDetectOverlapSec * m_sampleRate);
m_maxOverlapDiff = kMaxOctaveSecRate * kDetectOverlapSec;
m_pitchBufSize = (int)(((1.0f / (float)kMinFreq) * 2.0f + ((kAvgCount - 1) * kAvgOffset)) * m_sampleRate) + 16;
m_pitchBufLo = new float[m_pitchBufSize + m_detectOverlapSamples];
m_pitchBufHi = new float[m_pitchBufSize + m_detectOverlapSamples];
m_samplesPerPitchBlock = (int)Math.Round(m_sampleRate / m_pitchRecordsPerSecond);
m_circularBufferLo = new CircularBuffer<float>((int)(kCircularBufSaveTime * m_sampleRate + 0.5f) + 10000);
m_circularBufferHi = new CircularBuffer<float>((int)(kCircularBufSaveTime * m_sampleRate + 0.5f) + 10000);
}
/// <summary>
/// The pitch was detected - add the record
/// </summary>
/// <param name="pitch"></param>
private void AddPitchRecord(float pitch)
{
int midiNote = 0;
int midiCents = 0;
PitchDsp.PitchToMidiNote(pitch, out midiNote, out midiCents);
var record = new PitchRecord();
record.RecordIndex = m_curPitchIndex;
record.Pitch = pitch;
record.MidiNote = midiNote;
record.MidiCents = midiCents;
m_curPitchRecord = record;
if (m_recordPitchRecords)
{
if (m_pitchRecordHistorySize > 0 && m_pitchRecords.Count >= m_pitchRecordHistorySize)
m_pitchRecords.RemoveAt(0);
m_pitchRecords.Add(record);
}
if (this.PitchDetected != null)
this.PitchDetected(this, record);
}
/// <summary>
/// Stores one record
/// </summary>
public struct PitchRecord
{
/// <summary>
/// The index of the pitch record since the last Reset call
/// </summary>
public int RecordIndex { get; set; }
/// <summary>
/// The detected pitch
/// </summary>
public float Pitch { get; set; }
/// <summary>
/// The detected MIDI note, or 0 for no pitch
/// </summary>
public int MidiNote { get; set; }
/// <summary>
/// The offset from the detected MIDI note in cents, from -50 to +50.
/// </summary>
public int MidiCents { get; set; }
}
}
// ReSharper restore InconsistentNaming
}
-1
View File
@@ -63,7 +63,6 @@ namespace Vocaluxe.Lib.Webcam
/// <summary>
/// Gets the last captured frame as a bitma
/// </summary>
/// <param name="frame"></param>
/// <returns>Null if no frame was captured, the bitmap otherwise</returns>
Bitmap GetBitmap();
+2 -2
View File
@@ -257,8 +257,8 @@ namespace Vocaluxe.Screens
_Config.Height = d.Capabilities[_CapabilityNr].Height;
_Config.Framerate = d.Capabilities[_CapabilityNr].Framerate;
CWebcam.Select(_Config);
CWebcam.Start();
if (CWebcam.Select(_Config))
CWebcam.Start();
}
}
+1 -1
View File
@@ -298,7 +298,7 @@ namespace Vocaluxe.Screens
else
finish = true;
if (finish)
if (finish && !_FadeOut)
_LoadNextSong();
_UpdateSongText();
-6
View File
@@ -292,13 +292,7 @@
<Compile Include="Lib\Sound\Record\PitchTracker\CPitchTrackerTest.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\CPtAKF.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\CPtDyWa.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\CPtSharp.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\IPitchTracker.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\Pitch\CircularBuffer.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\Pitch\Extensions.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\Pitch\IIRFilter.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\Pitch\PitchDsp.cs" />
<Compile Include="Lib\Sound\Record\PitchTracker\Pitch\PitchTracker.cs" />
<Compile Include="Lib\Video\Acinerella\CDecoder.cs" />
<Compile Include="Lib\Video\Acinerella\CDecoderThread.cs" />
<Compile Include="Lib\Video\Acinerella\CFramebuffer.cs" />
+2
View File
@@ -27,9 +27,11 @@ namespace VocaluxeLib
public struct SThemeFont
{
// ReSharper disable UnassignedField.Global
public string Name;
public EStyle Style;
public float Size;
// ReSharper restore UnassignedField.Global
}
public class CFont
+15 -15
View File
@@ -48,7 +48,6 @@ namespace VocaluxeLib.Menu
{
private readonly int _PartyModeID;
private SThemeBackground _Theme;
private bool _ThemeLoaded;
private int _SlideShowCurrent;
private readonly Stopwatch _SlideShowTimer = new Stopwatch();
@@ -62,10 +61,7 @@ namespace VocaluxeLib.Menu
}
public SColorF Color;
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public string GetThemeName()
{
@@ -76,7 +72,7 @@ namespace VocaluxeLib.Menu
public CBackground(int partyModeID)
{
_PartyModeID = partyModeID;
_ThemeLoaded = false;
ThemeLoaded = false;
_Theme = new SThemeBackground {SlideShowTextures = new List<string>()};
Color = new SColorF(0f, 0f, 0f, 1f);
@@ -87,7 +83,7 @@ namespace VocaluxeLib.Menu
_Theme = theme;
_PartyModeID = partyModeID;
LoadSkin();
ThemeLoaded = true;
}
#endregion Constructors
@@ -95,16 +91,16 @@ namespace VocaluxeLib.Menu
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
bool vid = xmlReader.GetValue(item + "/Video", out _Theme.VideoName, String.Empty);
bool tex = xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
_ThemeLoaded &= vid || tex || _Theme.Type == EBackgroundTypes.None;
ThemeLoaded &= vid || tex || _Theme.Type == EBackgroundTypes.None;
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
bool success = true;
@@ -114,7 +110,7 @@ namespace VocaluxeLib.Menu
success &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
if (_Theme.Type != EBackgroundTypes.None)
_ThemeLoaded &= success;
ThemeLoaded &= success;
}
_Theme.Color.Color = Color;
@@ -130,12 +126,12 @@ namespace VocaluxeLib.Menu
i++;
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void Resume()
@@ -179,12 +175,16 @@ namespace VocaluxeLib.Menu
public void UnloadSkin()
{
if (!ThemeLoaded)
return;
_SlideShowTextures.Clear();
CBase.Video.Close(ref _VideoStream);
}
public void LoadSkin()
{
if (!ThemeLoaded)
return;
_Theme.Color.Get(_PartyModeID, out Color);
if (_Theme.Type == EBackgroundTypes.SlideShow)
@@ -224,7 +224,7 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeBackground GetTheme()
public object GetTheme()
{
return _Theme;
}
+44 -38
View File
@@ -42,7 +42,6 @@ namespace VocaluxeLib.Menu
public sealed class CButton : CMenuElementBase, IMenuElement, IThemeable
{
private SThemeButton _Theme;
private bool _ThemeLoaded;
private readonly int _PartyModeID;
public CTextureRef Texture;
@@ -100,10 +99,7 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public CButton(int partyModeID)
{
@@ -125,7 +121,7 @@ namespace VocaluxeLib.Menu
Selected = false;
EditMode = false;
LoadSkin();
ThemeLoaded = true;
}
public CButton(CButton button)
@@ -161,42 +157,42 @@ namespace VocaluxeLib.Menu
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinSelected", out _Theme.SkinSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinSelected", out _Theme.SkinSelected, String.Empty);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColor.Name, String.Empty))
_ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out SelColor);
ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out SelColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref SelColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref SelColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref SelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref SelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
}
_ThemeLoaded &= Text.LoadTheme(item, "Text", xmlReader, true);
ThemeLoaded &= Text.LoadTheme(item, "Text", xmlReader, true);
Text.Z = Rect.Z;
if (xmlReader.ItemExists(item + "/SText"))
{
_ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, true);
ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, true);
_SelText.Z = Rect.Z;
}
else
@@ -207,8 +203,8 @@ namespace VocaluxeLib.Menu
if (xmlReader.ItemExists(item + "/Reflection"))
{
_Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
_Theme.Reflection = new SReflection(_ReflectionHeight, _ReflectionSpace);
}
@@ -221,8 +217,8 @@ namespace VocaluxeLib.Menu
if (xmlReader.ItemExists(item + "/SReflection"))
{
_SelReflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref _SelReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref _SelReflectionHeight);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref _SelReflectionSpace);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref _SelReflectionHeight);
_Theme.SelReflection = new SReflection(_SelReflectionHeight, _SelReflectionSpace);
}
@@ -232,20 +228,25 @@ namespace VocaluxeLib.Menu
_Theme.SelReflection = null;
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = Color;
_Theme.SelColor.Color = SelColor;
_Theme.Text = Text.GetTheme();
if (_SelText == null)
_Theme.SelText = null;
else
_Theme.SelText = _SelText.GetTheme();
_ReadSubThemeElements();
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
private void _ReadSubThemeElements()
{
_Theme.Text = (SThemeText)Text.GetTheme();
if (_SelText == null)
_Theme.SelText = null;
else
_Theme.SelText = (SThemeText)_SelText.GetTheme();
}
public void Draw()
@@ -306,11 +307,15 @@ namespace VocaluxeLib.Menu
public void UnloadSkin()
{
if (!ThemeLoaded)
return;
Text.UnloadSkin();
}
public void LoadSkin()
{
if (!ThemeLoaded)
return;
Text = new CText(_Theme.Text, _PartyModeID);
Text.LoadSkin();
@@ -351,8 +356,9 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeButton GetTheme()
public object GetTheme()
{
_ReadSubThemeElements();
return _Theme;
}
+29 -33
View File
@@ -50,7 +50,6 @@ namespace VocaluxeLib.Menu
{
private readonly int _PartyModeID;
private SThemeEqualizer _Theme;
private bool _ThemeLoaded;
public SColorF Color;
public SColorF MaxColor;
@@ -65,10 +64,7 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
private float[] _Bars;
private int _MaxBar;
@@ -83,7 +79,7 @@ namespace VocaluxeLib.Menu
{
_PartyModeID = partyModeID;
_Theme = new SThemeEqualizer();
_ThemeLoaded = false;
ThemeLoaded = false;
Color = new SColorF();
MaxColor = new SColorF();
@@ -98,56 +94,56 @@ namespace VocaluxeLib.Menu
_PartyModeID = partyModeID;
_Theme = theme;
LoadSkin();
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/NumBars", ref _Theme.NumBars);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/NumBars", ref _Theme.NumBars);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Space", ref _Theme.Space);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Space", ref _Theme.Space);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.Style);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.Style);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/DrawNegative", ref _Theme.DrawNegative);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/DrawNegative", ref _Theme.DrawNegative);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/MaxColor", out _Theme.MaxColor.Name, String.Empty))
_ThemeLoaded &= _Theme.MaxColor.Get(_PartyModeID, out MaxColor);
ThemeLoaded &= _Theme.MaxColor.Get(_PartyModeID, out MaxColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxR", ref MaxColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxG", ref MaxColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxB", ref MaxColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxA", ref MaxColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxR", ref MaxColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxG", ref MaxColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxB", ref MaxColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/MaxA", ref MaxColor.A);
}
//Reflection
if (xmlReader.ItemExists(item + "/Reflection"))
{
Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
_Theme.Reflection = new SReflection(ReflectionHeight, ReflectionSpace);
}
@@ -157,14 +153,14 @@ namespace VocaluxeLib.Menu
_Theme.Reflection = null;
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = Color;
_Theme.MaxColor.Color = MaxColor;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void Update(float[] weights, float volume)
@@ -264,7 +260,7 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeEqualizer GetTheme()
public object GetTheme()
{
return _Theme;
}
+1 -1
View File
@@ -33,7 +33,7 @@ namespace VocaluxeLib.Menu
ParticleEffect
}
class CInteraction
public class CInteraction
{
public readonly int Num;
public readonly EType Type;
+22 -26
View File
@@ -37,7 +37,6 @@ namespace VocaluxeLib.Menu
{
private readonly int _PartyModeID;
private SThemeLyrics _Theme;
private bool _ThemeLoaded;
/// <summary>
/// Holds a reference to Songline. DO NOT MODIFY
@@ -61,10 +60,7 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
private SColorF _Color;
private SColorF _ColorProcessed;
@@ -85,7 +81,7 @@ namespace VocaluxeLib.Menu
{
_PartyModeID = partyModeID;
_Theme = new SThemeLyrics();
_ThemeLoaded = false;
ThemeLoaded = false;
_Color = new SColorF();
_ColorProcessed = new SColorF();
@@ -106,48 +102,48 @@ namespace VocaluxeLib.Menu
LyricStyle = ELyricStyle.Fill;
LoadSkin();
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.ProcessedColor.Name, String.Empty))
_ThemeLoaded &= _Theme.ProcessedColor.Get(_PartyModeID, out _ColorProcessed);
ThemeLoaded &= _Theme.ProcessedColor.Get(_PartyModeID, out _ColorProcessed);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _ColorProcessed.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _ColorProcessed.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _ColorProcessed.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _ColorProcessed.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _ColorProcessed.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _ColorProcessed.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _ColorProcessed.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _ColorProcessed.A);
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = _Color;
_Theme.ProcessedColor.Color = _ColorProcessed;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void SetLine(CSongLine line)
@@ -441,7 +437,7 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeLyrics GetTheme()
public object GetTheme()
{
return _Theme;
}
+54 -120
View File
@@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Windows.Forms;
using System.Xml.Serialization;
using VocaluxeLib.Draw;
@@ -49,7 +50,7 @@ namespace VocaluxeLib.Menu
[XmlArray("Equalizers")] public List<SThemeEqualizer> Equalizers;
[XmlArray("Playlists")] public List<SThemePlaylist> Playlists;
[XmlArray("ParticleEffects")] public List<SThemeParticleEffect> ParticleEffects;
[XmlArray("ScreenSettings")] public List<SScreenSetting> ScreenSettings;
[XmlArray("ScreenSettings")] public List<SThemeScreenSetting> ScreenSettings;
}
struct SZSort
@@ -64,7 +65,7 @@ namespace VocaluxeLib.Menu
protected abstract int _ScreenVersion { get; }
public int PartyModeID { get; protected set; }
public string ThemeName { get; set; }
public string ThemeName { get; private set; }
public SThemeScreen Theme;
// ReSharper disable MemberCanBePrivate.Global
@@ -161,7 +162,7 @@ namespace VocaluxeLib.Menu
Theme.Equalizers = new List<SThemeEqualizer>();
Theme.Playlists = new List<SThemePlaylist>();
Theme.ParticleEffects = new List<SThemeParticleEffect>();
Theme.ScreenSettings = new List<SScreenSetting>();
Theme.ScreenSettings = new List<SThemeScreenSetting>();
try
{
@@ -190,7 +191,7 @@ namespace VocaluxeLib.Menu
foreach (SThemePlaylist pl in Theme.Playlists)
_AddPlaylist(new CPlaylist(pl, PartyModeID), pl.Name);
foreach (SScreenSetting ss in Theme.ScreenSettings)
foreach (SThemeScreenSetting ss in Theme.ScreenSettings)
_AddScreenSetting(new CScreenSetting(ss, PartyModeID), ss.Name);
foreach (SThemeSelectSlide sl in Theme.SelectSlides)
@@ -200,13 +201,27 @@ namespace VocaluxeLib.Menu
_AddSingNote(new CSingNotes(sb, PartyModeID), sb.Name);
foreach (SThemeSongMenu sm in Theme.SongMenus)
_AddSongMenu(CSongMenuFactory.GetSongMenu(sm, PartyModeID), sm.Name);
_AddSongMenu(CSongMenuFactory.CreateSongMenu(sm, PartyModeID), sm.Name);
foreach (SThemeStatic st in Theme.Statics)
_AddStatic(new CStatic(st, PartyModeID), st.Name);
foreach (SThemeText te in Theme.Texts)
_AddText(new CText(te, PartyModeID), te.Name);
if (_ScreenVersion != Theme.Informations.ScreenVersion)
{
string msg = "Can't load screen file of screen \"" + ThemeName + "\", ";
if (Theme.Informations.ScreenVersion < _ScreenVersion)
msg += "the file ist outdated! ";
else
msg += "the file is for newer program versions! ";
msg += "Current screen version is " + _ScreenVersion;
CBase.Log.LogError(msg);
}
foreach (IThemeable el in _Elements.Select(_GetElement).OfType<IThemeable>())
el.LoadSkin();
}
catch (InvalidOperationException)
{
@@ -216,17 +231,6 @@ namespace VocaluxeLib.Menu
{
CBase.Log.LogError(e.Message + e.StackTrace, true, true);
}
if (_ScreenVersion != Theme.Informations.ScreenVersion)
{
string msg = "Can't load screen file of screen \"" + ThemeName + "\", ";
if (Theme.Informations.ScreenVersion < _ScreenVersion)
msg += "the file ist outdated! ";
else
msg += "the file is for newer program versions! ";
msg += "Current screen version is " + _ScreenVersion;
CBase.Log.LogError(msg);
}
}
private void _AddScreenSetting(CScreenSetting screenSetting, string name)
@@ -234,7 +238,7 @@ namespace VocaluxeLib.Menu
_ScreenSettings.Add(name, screenSetting);
}
public virtual void LoadThemeOld(string xmlPath)
public void LoadThemeOld(string xmlPath)
{
string file = Path.Combine(xmlPath, ThemeName + ".xml");
@@ -256,7 +260,7 @@ namespace VocaluxeLib.Menu
_LoadThemeElement<CSelectSlide>(_ThemeSelectSlides, _AddSelectSlide, xmlReader);
foreach (string elName in _ThemeSongMenus)
{
ISongMenu element = CSongMenuFactory.GetSongMenu(PartyModeID);
ISongMenu element = CSongMenuFactory.CreateSongMenu(PartyModeID);
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader))
_AddSongMenu(element, elName);
else
@@ -286,44 +290,21 @@ namespace VocaluxeLib.Menu
Theme.Equalizers = new List<SThemeEqualizer>();
Theme.Playlists = new List<SThemePlaylist>();
Theme.ParticleEffects = new List<SThemeParticleEffect>();
Theme.ScreenSettings = new List<SScreenSetting>();
Theme.ScreenSettings = new List<SThemeScreenSetting>();
}
private static void _AddThemeablesToList<T, TT>(ICollection<TT> themeList, IEnumerable<T> objects) where T : IThemeable
{
themeList.Clear();
foreach (T el in objects.Where(el => el.ThemeLoaded))
themeList.Add((TT)el.GetTheme());
}
public virtual void SaveTheme()
{
if (CBase.Config.GetLoadOldThemeFiles())
{
//Have to add theme-stuff manually, later it will be done while de-serialization
foreach (CBackground el in _Backgrounds)
Theme.Backgrounds.Add(el.GetTheme());
foreach (CButton el in _Buttons)
Theme.Buttons.Add(el.GetTheme());
foreach (CEqualizer el in _Equalizers)
Theme.Equalizers.Add(el.GetTheme());
foreach (CLyric el in _Lyrics)
Theme.Lyrics.Add(el.GetTheme());
foreach (CNameSelection el in _NameSelections)
Theme.NameSelections.Add(el.GetTheme());
foreach (CParticleEffect el in _ParticleEffects)
Theme.ParticleEffects.Add(el.GetTheme());
foreach (CPlaylist el in _Playlists)
Theme.Playlists.Add(el.GetTheme());
foreach (CScreenSetting el in _ScreenSettings.Values)
Theme.ScreenSettings.Add(el.GetTheme());
foreach (CSelectSlide el in _SelectSlides)
Theme.SelectSlides.Add(el.GetTheme());
foreach (CStatic el in _Statics)
Theme.Statics.Add(el.GetTheme());
foreach (CText el in _Texts)
Theme.Texts.Add(el.GetTheme());
foreach (CSongMenuFramework el in _SongMenus)
Theme.SongMenus.Add(el.GetTheme());
foreach (CSingNotes el in _SingNotes)
Theme.SingNotes.Add(el.GetTheme());
}
if (string.IsNullOrEmpty(ThemePath))
return;
_ReadThemeSubElements();
try
{
@@ -340,82 +321,34 @@ namespace VocaluxeLib.Menu
}
}
private void _ReadThemeSubElements()
{
// Load changed/added theme elements into theme struct
_AddThemeablesToList(Theme.Backgrounds, _Backgrounds);
_AddThemeablesToList(Theme.Buttons, _Buttons);
_AddThemeablesToList(Theme.Equalizers, _Equalizers);
_AddThemeablesToList(Theme.Lyrics, _Lyrics);
_AddThemeablesToList(Theme.NameSelections, _NameSelections);
_AddThemeablesToList(Theme.ParticleEffects, _ParticleEffects);
_AddThemeablesToList(Theme.Playlists, _Playlists);
_AddThemeablesToList(Theme.ScreenSettings, _ScreenSettings.Values);
_AddThemeablesToList(Theme.SelectSlides, _SelectSlides);
_AddThemeablesToList(Theme.Statics, _Statics);
_AddThemeablesToList(Theme.Texts, _Texts);
_AddThemeablesToList(Theme.SongMenus, _SongMenus);
_AddThemeablesToList(Theme.SingNotes, _SingNotes);
}
public virtual void ReloadSkin()
{
foreach (CBackground background in _Backgrounds)
background.ReloadSkin();
foreach (CButton button in _Buttons)
button.ReloadSkin();
foreach (CText text in _Texts)
text.ReloadSkin();
foreach (CStatic stat in _Statics)
stat.ReloadSkin();
foreach (CSelectSlide slide in _SelectSlides)
slide.ReloadSkin();
foreach (CSongMenuFramework sm in _SongMenus)
sm.ReloadSkin();
foreach (CLyric lyric in _Lyrics)
lyric.ReloadSkin();
foreach (CSingNotes sn in _SingNotes)
sn.ReloadSkin();
foreach (CNameSelection ns in _NameSelections)
ns.ReloadSkin();
foreach (CEqualizer eq in _Equalizers)
eq.ReloadSkin();
foreach (CPlaylist pls in _Playlists)
pls.ReloadSkin();
foreach (CParticleEffect pe in _ParticleEffects)
pe.ReloadSkin();
foreach (IThemeable el in _Elements.Select(_GetElement).OfType<IThemeable>())
el.ReloadSkin();
}
public virtual void UnloadSkin()
{
foreach (CBackground background in _Backgrounds)
background.UnloadSkin();
foreach (CButton button in _Buttons)
button.UnloadSkin();
foreach (CText text in _Texts)
text.UnloadSkin();
foreach (CStatic stat in _Statics)
stat.UnloadSkin();
foreach (CSelectSlide slide in _SelectSlides)
slide.UnloadSkin();
foreach (CSongMenuFramework sm in _SongMenus)
sm.UnloadSkin();
foreach (CLyric lyric in _Lyrics)
lyric.UnloadSkin();
foreach (CSingNotes sn in _SingNotes)
sn.UnloadSkin();
foreach (CNameSelection ns in _NameSelections)
ns.UnloadSkin();
foreach (CPlaylist pls in _Playlists)
pls.UnloadSkin();
foreach (CEqualizer eq in _Equalizers)
eq.UnloadSkin();
foreach (CParticleEffect pe in _ParticleEffects)
pe.UnloadSkin();
foreach (IThemeable el in _Elements.Select(_GetElement).OfType<IThemeable>())
el.UnloadSkin();
}
public virtual void ReloadTheme(string xmlPath)
@@ -423,6 +356,7 @@ namespace VocaluxeLib.Menu
if (ThemePath == "")
return;
_ReadThemeSubElements();
UnloadSkin();
_ClearElements();
LoadTheme(xmlPath);
-1
View File
@@ -15,7 +15,6 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using VocaluxeLib.PartyModes;
namespace VocaluxeLib.Menu
+32 -36
View File
@@ -74,17 +74,13 @@ namespace VocaluxeLib.Menu
private readonly int _PartyModeID;
private SThemeNameSelection _Theme;
private bool _ThemeLoaded;
public string GetThemeName()
{
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
private readonly List<CTile> _Tiles;
@@ -139,7 +135,7 @@ namespace VocaluxeLib.Menu
_VisibleProfiles = new List<int>();
_UsedProfiles = new List<int>();
LoadSkin();
ThemeLoaded = true;
}
public void Init()
@@ -159,59 +155,59 @@ namespace VocaluxeLib.Menu
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinEmptyTile", out _Theme.SkinEmptyTile, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinEmptyTile", out _Theme.SkinEmptyTile, String.Empty);
if (xmlReader.GetValue(item + "/ColorEmptyTile", out _Theme.ColorEmptyTile.Name, String.Empty))
_ThemeLoaded &= _Theme.ColorEmptyTile.Get(_PartyModeID, out _ColorEmptyTile);
ThemeLoaded &= _Theme.ColorEmptyTile.Get(_PartyModeID, out _ColorEmptyTile);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _ColorEmptyTile.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _ColorEmptyTile.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _ColorEmptyTile.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _ColorEmptyTile.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _ColorEmptyTile.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _ColorEmptyTile.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _ColorEmptyTile.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _ColorEmptyTile.A);
}
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinTileSelected", out _Theme.SkinTileSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinTileSelected", out _Theme.SkinTileSelected, String.Empty);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/W", ref _Theme.Tiles.W);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/H", ref _Theme.Tiles.H);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/NumW", ref _Theme.Tiles.NumW);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/NumH", ref _Theme.Tiles.NumH);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/SpaceW", ref _Theme.Tiles.SpaceW);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/SpaceH", ref _Theme.Tiles.SpaceH);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/Space", ref _Theme.Tiles.Name.Space);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/H", ref _Theme.Tiles.Name.Height);
_ThemeLoaded &= xmlReader.GetValue(item + "/Tiles/Name/Font", out _Theme.Tiles.Name.Font, "Normal");
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Tiles/Name/Style", ref _Theme.Tiles.Name.Style);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/W", ref _Theme.Tiles.W);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/H", ref _Theme.Tiles.H);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/NumW", ref _Theme.Tiles.NumW);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/Tiles/NumH", ref _Theme.Tiles.NumH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/SpaceW", ref _Theme.Tiles.SpaceW);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/SpaceH", ref _Theme.Tiles.SpaceH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/Space", ref _Theme.Tiles.Name.Space);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/H", ref _Theme.Tiles.Name.Height);
ThemeLoaded &= xmlReader.GetValue(item + "/Tiles/Name/Font", out _Theme.Tiles.Name.Font, "Normal");
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Tiles/Name/Style", ref _Theme.Tiles.Name.Style);
if (xmlReader.GetValue(item + "/Tiles/Name/Color", out _Theme.Tiles.Name.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Tiles.Name.Color.Get(_PartyModeID, out _ColorNameTile);
ThemeLoaded &= _Theme.Tiles.Name.Color.Get(_PartyModeID, out _ColorNameTile);
else
{
if (xmlReader.TryGetFloatValue(item + "/Tiles/Name/R", ref _ColorNameTile.R))
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/G", ref _ColorNameTile.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/B", ref _ColorNameTile.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/A", ref _ColorNameTile.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/G", ref _ColorNameTile.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/B", ref _ColorNameTile.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Tiles/Name/A", ref _ColorNameTile.A);
}
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Tiles.Name.Color.Color = _ColorNameTile;
_Theme.ColorEmptyTile.Color = _ColorEmptyTile;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void Draw()
@@ -528,7 +524,7 @@ namespace VocaluxeLib.Menu
}
}
public SThemeNameSelection GetTheme()
public object GetTheme()
{
return _Theme;
}
+2 -2
View File
@@ -27,7 +27,7 @@ namespace VocaluxeLib.Menu
{
public abstract class CObjectInteractions
{
private readonly List<CInteraction> _Elements = new List<CInteraction>();
protected readonly List<CInteraction> _Elements = new List<CInteraction>();
private int _Selection;
private Point _PrevMouse;
@@ -245,7 +245,7 @@ namespace VocaluxeLib.Menu
return _Selection >= 0 && _Selection < _Elements.Count;
}
private IMenuElement _GetElement(CInteraction element)
protected IMenuElement _GetElement(CInteraction element)
{
switch (element.Type)
{
+20 -24
View File
@@ -50,7 +50,6 @@ namespace VocaluxeLib.Menu
{
private readonly int _PartyModeID;
private SThemeParticleEffect _Theme;
private bool _ThemeLoaded;
public CTextureRef Texture;
public SColorF Color;
@@ -66,10 +65,7 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public bool IsAlive
{
@@ -128,43 +124,43 @@ namespace VocaluxeLib.Menu
_NextSpawnTime = 0f;
Visible = true;
LoadSkin();
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Size", ref _Theme.Size);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/MaxNumber", ref _Theme.MaxNumber);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Type", ref _Theme.Type);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Size", ref _Theme.Size);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/MaxNumber", ref _Theme.MaxNumber);
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.Color.Color = Color;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void Update()
@@ -330,7 +326,7 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeParticleEffect GetTheme()
public object GetTheme()
{
return _Theme;
}
+59 -59
View File
@@ -144,17 +144,13 @@ namespace VocaluxeLib.Menu
private readonly int _PartyModeID;
private SThemePlaylist _Theme;
private bool _ThemeLoaded;
public string GetThemeName()
{
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
private readonly List<CPlaylistElement> _PlaylistElements = new List<CPlaylistElement>();
private readonly List<CPlaylistElementContent> _PlaylistElementContents = new List<CPlaylistElementContent>();
@@ -257,13 +253,6 @@ namespace VocaluxeLib.Menu
_ButtonPlaylistSing = new CButton(_Theme.ButtonPlaylistSing, _PartyModeID);
_SelectSlideGameMode = new CSelectSlide(_Theme.SelectSlideGameMode, _PartyModeID);
Visible = false;
Selected = false;
}
public override void Init()
{
base.Init();
_AddStatic(_StaticPlaylistFooter);
_AddStatic(_StaticPlaylistHeader);
_AddButton(_ButtonPlaylistName);
@@ -271,75 +260,83 @@ namespace VocaluxeLib.Menu
_AddButton(_ButtonPlaylistDelete);
_AddButton(_ButtonPlaylistSave);
_AddButton(_ButtonPlaylistSing);
LoadSkin();
Visible = false;
Selected = false;
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackground", out _Theme.SkinBackground, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundSelected", out _Theme.SkinBackgroundSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackground", out _Theme.SkinBackground, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundSelected", out _Theme.SkinBackgroundSelected, String.Empty);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/ColorBackground", out _Theme.ColorBackground.Name, String.Empty))
_ThemeLoaded &= _Theme.ColorBackground.Get(_PartyModeID, out _BackgroundColor);
ThemeLoaded &= _Theme.ColorBackground.Get(_PartyModeID, out _BackgroundColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundR", ref _BackgroundColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundG", ref _BackgroundColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundB", ref _BackgroundColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundA", ref _BackgroundColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundR", ref _BackgroundColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundG", ref _BackgroundColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundB", ref _BackgroundColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/BackgroundA", ref _BackgroundColor.A);
}
if (xmlReader.GetValue(item + "/SColorBackground", out _Theme.SelColorBackground.Name, String.Empty))
_ThemeLoaded &= _Theme.SelColorBackground.Get(_PartyModeID, out _BackgroundSelColor);
ThemeLoaded &= _Theme.SelColorBackground.Get(_PartyModeID, out _BackgroundSelColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundR", ref _BackgroundSelColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundG", ref _BackgroundSelColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundB", ref _BackgroundSelColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundA", ref _BackgroundSelColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundR", ref _BackgroundSelColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundG", ref _BackgroundSelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundB", ref _BackgroundSelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SBackgroundA", ref _BackgroundSelColor.A);
}
_ThemeLoaded &= _Text1.LoadTheme(item, "TextPart1", xmlReader);
ThemeLoaded &= _Text1.LoadTheme(item, "TextPart1", xmlReader);
CStatic tmpStatic = new CStatic(_PartyModeID);
_ThemeLoaded &= tmpStatic.LoadTheme(item, "StaticCover", xmlReader);
_ThemeLoaded &= _StaticPlaylistHeader.LoadTheme(item, "StaticPlaylistHeader", xmlReader);
_ThemeLoaded &= _StaticPlaylistFooter.LoadTheme(item, "StaticPlaylistFooter", xmlReader);
ThemeLoaded &= tmpStatic.LoadTheme(item, "StaticCover", xmlReader);
ThemeLoaded &= _StaticPlaylistHeader.LoadTheme(item, "StaticPlaylistHeader", xmlReader);
ThemeLoaded &= _StaticPlaylistFooter.LoadTheme(item, "StaticPlaylistFooter", xmlReader);
_ThemeLoaded &= _ButtonPlaylistName.LoadTheme(item, "ButtonPlaylistName", xmlReader);
_ThemeLoaded &= _ButtonPlaylistSing.LoadTheme(item, "ButtonPlaylistSing", xmlReader);
_ThemeLoaded &= _ButtonPlaylistClose.LoadTheme(item, "ButtonPlaylistClose", xmlReader);
_ThemeLoaded &= _ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader);
_ThemeLoaded &= _ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader);
ThemeLoaded &= _ButtonPlaylistName.LoadTheme(item, "ButtonPlaylistName", xmlReader);
ThemeLoaded &= _ButtonPlaylistSing.LoadTheme(item, "ButtonPlaylistSing", xmlReader);
ThemeLoaded &= _ButtonPlaylistClose.LoadTheme(item, "ButtonPlaylistClose", xmlReader);
ThemeLoaded &= _ButtonPlaylistSave.LoadTheme(item, "ButtonPlaylistSave", xmlReader);
ThemeLoaded &= _ButtonPlaylistDelete.LoadTheme(item, "ButtonPlaylistDelete", xmlReader);
_ThemeLoaded &= _SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader);
ThemeLoaded &= _SelectSlideGameMode.LoadTheme(item, "SelectSlideGameMode", xmlReader);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/EntryHeight", ref _Theme.EntryHeight);
if (_ThemeLoaded)
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/EntryHeight", ref _Theme.EntryHeight);
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.ColorBackground.Color = _BackgroundColor;
_Theme.SelColorBackground.Color = _BackgroundSelColor;
_Theme.Text1 = _Text1.GetTheme();
_Theme.StaticCover = tmpStatic.GetTheme();
_Theme.StaticPlaylistFooter = _StaticPlaylistFooter.GetTheme();
_Theme.StaticPlaylistHeader = _StaticPlaylistHeader.GetTheme();
_Theme.ButtonPlaylistName = _ButtonPlaylistName.GetTheme();
_Theme.ButtonPlaylistSing = _ButtonPlaylistSing.GetTheme();
_Theme.ButtonPlaylistClose = _ButtonPlaylistClose.GetTheme();
_Theme.ButtonPlaylistSave = _ButtonPlaylistSave.GetTheme();
_Theme.ButtonPlaylistDelete = _ButtonPlaylistDelete.GetTheme();
_Theme.StaticCover = (SThemeStatic)tmpStatic.GetTheme();
_ReadSubThemeElements();
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
private void _ReadSubThemeElements()
{
_Theme.Text1 = (SThemeText)_Text1.GetTheme();
_Theme.StaticPlaylistFooter = (SThemeStatic)_StaticPlaylistFooter.GetTheme();
_Theme.StaticPlaylistHeader = (SThemeStatic)_StaticPlaylistHeader.GetTheme();
_Theme.ButtonPlaylistName = (SThemeButton)_ButtonPlaylistName.GetTheme();
_Theme.ButtonPlaylistSing = (SThemeButton)_ButtonPlaylistSing.GetTheme();
_Theme.ButtonPlaylistClose = (SThemeButton)_ButtonPlaylistClose.GetTheme();
_Theme.ButtonPlaylistSave = (SThemeButton)_ButtonPlaylistSave.GetTheme();
_Theme.ButtonPlaylistDelete = (SThemeButton)_ButtonPlaylistDelete.GetTheme();
}
public void UpdateGame()
@@ -884,11 +881,13 @@ namespace VocaluxeLib.Menu
if (_ChangeOrderSource >= _PlaylistElementContents.Count)
return true;
_ChangeOrderElement = new CPlaylistElement(_PlaylistElements[_CurrentPlaylistElement]);
_ChangeOrderElement.Background.Z = CBase.Settings.GetZNear();
_ChangeOrderElement.Cover.Z = CBase.Settings.GetZNear();
_ChangeOrderElement.SelectSlide.Z = CBase.Settings.GetZNear();
_ChangeOrderElement.Text1.Z = CBase.Settings.GetZNear();
_ChangeOrderElement = new CPlaylistElement(_PlaylistElements[_CurrentPlaylistElement])
{
Background = {Z = CBase.Settings.GetZNear()},
Cover = {Z = CBase.Settings.GetZNear()},
SelectSlide = {Z = CBase.Settings.GetZNear()},
Text1 = {Z = CBase.Settings.GetZNear()}
};
_ChangeOrderElement.Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackground, _PartyModeID);
_ChangeOrderElement.Background.Color = _BackgroundColor;
@@ -1164,8 +1163,9 @@ namespace VocaluxeLib.Menu
}
}
public SThemePlaylist GetTheme()
public object GetTheme()
{
_ReadSubThemeElements();
return _Theme;
}
+5 -5
View File
@@ -31,7 +31,7 @@ namespace VocaluxeLib.Menu
}
[XmlType("ScreenSetting")]
public struct SScreenSetting
public struct SThemeScreenSetting
{
[XmlAttribute(AttributeName = "Name")] public string Name;
public string Value;
@@ -45,7 +45,7 @@ namespace VocaluxeLib.Menu
{
private readonly int _PartyModeID;
private SScreenSetting _Theme;
private SThemeScreenSetting _Theme;
private bool _ThemeLoaded;
public string GetThemeName()
@@ -61,11 +61,11 @@ namespace VocaluxeLib.Menu
public CScreenSetting(int partyModeID)
{
_PartyModeID = partyModeID;
_Theme = new SScreenSetting();
_Theme = new SThemeScreenSetting();
_ThemeLoaded = false;
}
public CScreenSetting(SScreenSetting theme, int partyModeID)
public CScreenSetting(SThemeScreenSetting theme, int partyModeID)
{
_PartyModeID = partyModeID;
_Theme = theme;
@@ -104,7 +104,7 @@ namespace VocaluxeLib.Menu
return null;
}
public SScreenSetting GetTheme()
public object GetTheme()
{
return _Theme;
}
+64 -68
View File
@@ -65,17 +65,13 @@ namespace VocaluxeLib.Menu
{
private readonly int _PartyModeID;
private SThemeSelectSlide _Theme;
private bool _ThemeLoaded;
public string GetThemeName()
{
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public SRectF RectArrowLeft;
public SRectF RectArrowRight;
@@ -211,7 +207,7 @@ namespace VocaluxeLib.Menu
public CSelectSlide(int partyModeID)
{
_PartyModeID = partyModeID;
_ThemeLoaded = false;
ThemeLoaded = false;
_TextH = 1f;
_MaxW = 0f;
@@ -226,7 +222,7 @@ namespace VocaluxeLib.Menu
_PartyModeID = slide._PartyModeID;
_Theme = slide._Theme;
_ThemeLoaded = false;
ThemeLoaded = false;
MaxRect = slide.MaxRect;
RectArrowLeft = slide.RectArrowLeft;
@@ -267,110 +263,110 @@ namespace VocaluxeLib.Menu
_ValueNames = new List<string>();
_ValuePartyModeIDs = new List<int>();
LoadSkin();
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowLeft", out _Theme.SkinArrowLeft, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowRight", out _Theme.SkinArrowRight, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowLeft", out _Theme.SkinArrowLeft, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowRight", out _Theme.SkinArrowRight, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinSelected", out _Theme.SkinSelected, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowLeftSelected", out _Theme.SkinArrowLeftSelected, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowRightSelected", out _Theme.SkinArrowRightSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinSelected", out _Theme.SkinSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowLeftSelected", out _Theme.SkinArrowLeftSelected, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinArrowRightSelected", out _Theme.SkinArrowRightSelected, String.Empty);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColor.Name, String.Empty))
_ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out _SelColor);
ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out _SelColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _SelColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _SelColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _SelColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _SelColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SR", ref _SelColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref _SelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref _SelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref _SelColor.A);
}
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftX", ref RectArrowLeft.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftY", ref RectArrowLeft.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftZ", ref RectArrowLeft.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftW", ref RectArrowLeft.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftH", ref RectArrowLeft.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftX", ref RectArrowLeft.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftY", ref RectArrowLeft.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftZ", ref RectArrowLeft.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftW", ref RectArrowLeft.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowLeftH", ref RectArrowLeft.H);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightX", ref RectArrowRight.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightY", ref RectArrowRight.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightZ", ref RectArrowRight.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightW", ref RectArrowRight.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightH", ref RectArrowRight.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightX", ref RectArrowRight.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightY", ref RectArrowRight.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightZ", ref RectArrowRight.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightW", ref RectArrowRight.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowRightH", ref RectArrowRight.H);
if (xmlReader.GetValue(item + "/ArrowColor", out _Theme.ArrowColor.Name, String.Empty))
_ThemeLoaded &= _Theme.ArrowColor.Get(_PartyModeID, out _ColorArrow);
ThemeLoaded &= _Theme.ArrowColor.Get(_PartyModeID, out _ColorArrow);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowR", ref _ColorArrow.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowG", ref _ColorArrow.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowB", ref _ColorArrow.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowA", ref _ColorArrow.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowR", ref _ColorArrow.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowG", ref _ColorArrow.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowB", ref _ColorArrow.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowA", ref _ColorArrow.A);
}
if (xmlReader.GetValue(item + "/ArrowSColor", out _Theme.ArrowSelColor.Name, String.Empty))
_ThemeLoaded &= _Theme.ArrowSelColor.Get(_PartyModeID, out _SelColorArrow);
ThemeLoaded &= _Theme.ArrowSelColor.Get(_PartyModeID, out _SelColorArrow);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSR", ref _SelColorArrow.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSG", ref _SelColorArrow.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSB", ref _SelColorArrow.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSA", ref _SelColorArrow.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSR", ref _SelColorArrow.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSG", ref _SelColorArrow.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSB", ref _SelColorArrow.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/ArrowSA", ref _SelColorArrow.A);
}
if (xmlReader.GetValue(item + "/TextColor", out _Theme.TextColor.Name, String.Empty))
_ThemeLoaded &= _Theme.TextColor.Get(_PartyModeID, out _TextColor);
ThemeLoaded &= _Theme.TextColor.Get(_PartyModeID, out _TextColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextR", ref _TextColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextG", ref _TextColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextB", ref _TextColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextA", ref _TextColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextR", ref _TextColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextG", ref _TextColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextB", ref _TextColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextA", ref _TextColor.A);
}
if (xmlReader.GetValue(item + "/TextSColor", out _Theme.TextSelColor.Name, String.Empty))
_ThemeLoaded &= _Theme.TextSelColor.Get(_PartyModeID, out _SelTextColor);
ThemeLoaded &= _Theme.TextSelColor.Get(_PartyModeID, out _SelTextColor);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSR", ref _SelTextColor.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSG", ref _SelTextColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSB", ref _SelTextColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSA", ref _SelTextColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSR", ref _SelTextColor.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSG", ref _SelTextColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSB", ref _SelTextColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextSA", ref _SelTextColor.A);
}
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextH", ref _Theme.TextH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextH", ref _Theme.TextH);
xmlReader.TryGetFloatValue(item + "/TextRelativeX", ref _Theme.TextRelativeX);
xmlReader.TryGetFloatValue(item + "/TextRelativeY", ref _Theme.TextRelativeY);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextMaxW", ref _Theme.TextMaxW);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/TextMaxW", ref _Theme.TextMaxW);
_ThemeLoaded &= xmlReader.GetValue(item + "/TextFont", out _Theme.TextFont, "Normal");
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/TextStyle", ref _Theme.TextStyle);
ThemeLoaded &= xmlReader.GetValue(item + "/TextFont", out _Theme.TextFont, "Normal");
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/TextStyle", ref _Theme.TextStyle);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/NumVisible", ref _Theme.NumVisible);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/NumVisible", ref _Theme.NumVisible);
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
_Theme.ArrowColor.Color = _ColorArrow;
@@ -383,7 +379,7 @@ namespace VocaluxeLib.Menu
_Theme.TextSelColor.Color = _SelTextColor;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void AddValue(string value)
@@ -656,7 +652,7 @@ namespace VocaluxeLib.Menu
}
}
public SThemeSelectSlide GetTheme()
public object GetTheme()
{
return _Theme;
}
+21 -24
View File
@@ -38,17 +38,13 @@ namespace VocaluxeLib.Menu
private readonly int _PartyModeID;
private SThemeStatic _Theme;
private bool _ThemeLoaded;
public string GetThemeName()
{
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public bool Selectable
{
@@ -114,31 +110,30 @@ namespace VocaluxeLib.Menu
{
_PartyModeID = partyModeID;
_Theme = theme;
LoadSkin();
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/Skin", out _Theme.Skin, String.Empty);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.Rect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Rect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Rect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/W", ref _Theme.Rect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.Rect.H);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
_Theme.Color.Color = Color;
@@ -146,8 +141,8 @@ namespace VocaluxeLib.Menu
if (xmlReader.ItemExists(item + "/Reflection"))
{
Reflection = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
_Theme.Reflection = new SReflection(ReflectionHeight, ReflectionSpace);
}
else
@@ -156,12 +151,12 @@ namespace VocaluxeLib.Menu
_Theme.Reflection = null;
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void Draw()
@@ -196,6 +191,8 @@ namespace VocaluxeLib.Menu
public void LoadSkin()
{
if (!ThemeLoaded)
return;
_Theme.Color.Get(_PartyModeID, out Color);
MaxRect = _Theme.Rect;
@@ -214,7 +211,7 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeStatic GetTheme()
public object GetTheme()
{
return _Theme;
}
+28 -32
View File
@@ -45,7 +45,6 @@ namespace VocaluxeLib.Menu
public sealed class CText : CMenuElementBase, IMenuElement, IThemeable, IFontObserver
{
private SThemeText _Theme;
private bool _ThemeLoaded;
private readonly int _PartyModeID = -1;
private int _TranslationID = -1;
@@ -54,10 +53,7 @@ namespace VocaluxeLib.Menu
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
private bool _ButtonText;
private bool _PositionNeedsUpdate = true;
@@ -266,7 +262,7 @@ namespace VocaluxeLib.Menu
float rspace = 0) : this(partyModeID)
{
_Theme = new SThemeText {FontFamily = fontFamily, FontStyle = style, FontHeight = h, Text = text};
_ThemeLoaded = false;
ThemeLoaded = false;
_ButtonText = false;
MaxRect = new SRectF(x, y, mw, h, z);
@@ -295,7 +291,7 @@ namespace VocaluxeLib.Menu
_ButtonText = buttonText;
LoadSkin();
ThemeLoaded = true;
}
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
@@ -306,50 +302,50 @@ namespace VocaluxeLib.Menu
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader, bool buttonText)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/X", ref _Theme.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Y", ref _Theme.Y);
if (!buttonText)
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Z", ref _Theme.Z);
xmlReader.TryGetFloatValue(item + "/MaxW", ref _Theme.MaxWidth);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out Color);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref Color.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref Color.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref Color.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref Color.A);
}
if (xmlReader.GetValue(item + "/SColor", out _Theme.SelColor.Name, String.Empty))
_ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out SelColor);
ThemeLoaded &= _Theme.SelColor.Get(_PartyModeID, out SelColor);
else
{
if (xmlReader.TryGetFloatValue(item + "/SR", ref SelColor.R))
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref SelColor.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref SelColor.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SG", ref SelColor.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SB", ref SelColor.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
}
}
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Align", ref _Align);
ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Align", ref _Align);
xmlReader.TryGetEnumValue(item + "/ResizeAlign", ref _ResizeAlign);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/H", ref _Theme.FontHeight);
_ThemeLoaded &= xmlReader.TryGetEnumValue(item + "/Style", ref _Theme.FontStyle);
_ThemeLoaded &= xmlReader.GetValue(item + "/Font", out _Theme.FontFamily);
ThemeLoaded &= xmlReader.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);
ThemeLoaded &= xmlReader.GetValue(item + "/Text", out _Theme.Text);
if (xmlReader.ItemExists(item + "/Reflection") && !buttonText)
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
_Theme.Reflection = new SReflection(_ReflectionHeight, _ReflectionSpace);
}
else
@@ -366,9 +362,9 @@ namespace VocaluxeLib.Menu
_ButtonText = buttonText;
_PositionNeedsUpdate = true;
if (_ThemeLoaded)
if (ThemeLoaded)
LoadSkin();
return _ThemeLoaded;
return ThemeLoaded;
}
public void Draw()
@@ -436,6 +432,8 @@ namespace VocaluxeLib.Menu
public void LoadSkin()
{
if (!ThemeLoaded)
return;
_Theme.Color.Get(_PartyModeID, out Color);
_Theme.SelColor.Get(_PartyModeID, out SelColor);
@@ -457,8 +455,6 @@ namespace VocaluxeLib.Menu
Text = _Theme.Text;
Selected = false;
_ThemeLoaded = true;
}
public void ReloadSkin()
@@ -467,7 +463,7 @@ namespace VocaluxeLib.Menu
LoadSkin();
}
public SThemeText GetTheme()
public object GetTheme()
{
return _Theme;
}
+2
View File
@@ -22,6 +22,8 @@ namespace VocaluxeLib.Menu
public interface IThemeable
{
string GetThemeName();
object GetTheme();
bool ThemeLoaded { get; }
bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader);
+21 -25
View File
@@ -53,7 +53,6 @@ namespace VocaluxeLib.Menu.SingNotes
{
private readonly int _PartyModeID;
private SThemeSingBar _Theme;
private bool _ThemeLoaded;
public readonly List<CNoteBars> PlayerNotes = new List<CNoteBars>();
@@ -74,7 +73,7 @@ namespace VocaluxeLib.Menu.SingNotes
{
_PartyModeID = partyModeID;
_Theme = new SThemeSingBar {BarPos = new SBarPosition[CHelper.Sum(CBase.Settings.GetMaxNumPlayer())]};
_ThemeLoaded = false;
ThemeLoaded = false;
}
public CSingNotes(SThemeSingBar theme, int partyModeID)
@@ -84,7 +83,7 @@ namespace VocaluxeLib.Menu.SingNotes
_BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
LoadSkin();
ThemeLoaded = true;
}
public string GetThemeName()
@@ -92,27 +91,24 @@ namespace VocaluxeLib.Menu.SingNotes
return _Theme.Name;
}
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinLeft", out _Theme.SkinLeft, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinMiddle", out _Theme.SkinMiddle, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinRight", out _Theme.SkinRight, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinLeft", out _Theme.SkinLeft, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinMiddle", out _Theme.SkinMiddle, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinRight", out _Theme.SkinRight, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundLeft", out _Theme.SkinBackgroundLeft, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundMiddle", out _Theme.SkinBackgroundMiddle, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundRight", out _Theme.SkinBackgroundRight, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundLeft", out _Theme.SkinBackgroundLeft, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundMiddle", out _Theme.SkinBackgroundMiddle, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinBackgroundRight", out _Theme.SkinBackgroundRight, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinGoldenStar", out _Theme.SkinGoldenStar, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinToneHelper", out _Theme.SkinToneHelper, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinPerfectNoteStar", out _Theme.SkinPerfectNoteStart, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinGoldenStar", out _Theme.SkinGoldenStar, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinToneHelper", out _Theme.SkinToneHelper, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/SkinPerfectNoteStar", out _Theme.SkinPerfectNoteStart, String.Empty);
int i = 0;
_BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
@@ -122,24 +118,24 @@ namespace VocaluxeLib.Menu.SingNotes
{
_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);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "X", ref _BarPos[player, numplayer].X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Y", ref _BarPos[player, numplayer].Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Z", ref _BarPos[player, numplayer].Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "W", ref _BarPos[player, numplayer].W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "H", ref _BarPos[player, numplayer].H);
_Theme.BarPos[i].Name = "P" + (player + 1) + "N" + (numplayer + 1);
_Theme.BarPos[i].Rect = _BarPos[player, numplayer];
i++;
}
}
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
LoadSkin();
}
return _ThemeLoaded;
return ThemeLoaded;
}
public void Init(int numPlayers)
@@ -174,7 +170,7 @@ namespace VocaluxeLib.Menu.SingNotes
LoadSkin();
}
public SThemeSingBar GetTheme()
public object GetTheme()
{
return _Theme;
}
@@ -21,7 +21,7 @@ namespace VocaluxeLib.Menu.SongMenu
{
public static class CSongMenuFactory
{
public static ISongMenu GetSongMenu(SThemeSongMenu theme, int partyModeID)
public static ISongMenu CreateSongMenu(SThemeSongMenu theme, int partyModeID)
{
switch (CBase.Config.GetSongMenuType())
{
@@ -47,7 +47,7 @@ namespace VocaluxeLib.Menu.SongMenu
/// </summary>
/// <param name="partyModeID"></param>
/// <returns></returns>
public static ISongMenu GetSongMenu(int partyModeID)
public static ISongMenu CreateSongMenu(int partyModeID)
{
switch (CBase.Config.GetSongMenuType())
{
+33 -37
View File
@@ -94,12 +94,8 @@ namespace VocaluxeLib.Menu.SongMenu
{
protected readonly int _PartyModeID;
protected SThemeSongMenu _Theme;
private bool _ThemeLoaded;
public bool ThemeLoaded
{
get { return _ThemeLoaded; }
}
public bool ThemeLoaded { get; private set; }
public bool Selectable
{
@@ -160,7 +156,7 @@ namespace VocaluxeLib.Menu.SongMenu
_PartyModeID = partyModeID;
_Theme = theme;
LoadSkin();
ThemeLoaded = true;
}
#region Theme
@@ -169,7 +165,7 @@ namespace VocaluxeLib.Menu.SongMenu
return _Theme.Name;
}
public SThemeSongMenu GetTheme()
public virtual object GetTheme()
{
return _Theme;
}
@@ -177,49 +173,49 @@ namespace VocaluxeLib.Menu.SongMenu
public virtual bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
ThemeLoaded = true;
_ThemeLoaded &= xmlReader.GetValue(item + "/CoverBackground", out _Theme.CoverBackground, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/CoverBigBackground", out _Theme.CoverBigBackground, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/DuetIcon", out _Theme.DuetIcon, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/VideoIcon", out _Theme.VideoIcon, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/MedleyCalcIcon", out _Theme.MedleyCalcIcon, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/MedleyTagIcon", out _Theme.MedleyTagIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/CoverBackground", out _Theme.CoverBackground, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/CoverBigBackground", out _Theme.CoverBigBackground, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/DuetIcon", out _Theme.DuetIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/VideoIcon", out _Theme.VideoIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/MedleyCalcIcon", out _Theme.MedleyCalcIcon, String.Empty);
ThemeLoaded &= xmlReader.GetValue(item + "/MedleyTagIcon", out _Theme.MedleyTagIcon, String.Empty);
if (xmlReader.GetValue(item + "/Color", out _Theme.Color.Name, String.Empty))
_ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _ColorInternal);
ThemeLoaded &= _Theme.Color.Get(_PartyModeID, out _ColorInternal);
else
{
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _ColorInternal.R);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _ColorInternal.G);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _ColorInternal.B);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _ColorInternal.A);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/R", ref _ColorInternal.R);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/G", ref _ColorInternal.G);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/B", ref _ColorInternal.B);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/A", ref _ColorInternal.A);
}
_Theme.Color.Color = _ColorInternal;
#region SongMenuTileBoard
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumW", ref _Theme.SongMenuTileBoard.NumW);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumH", ref _Theme.SongMenuTileBoard.NumH);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/SpaceW", ref _Theme.SongMenuTileBoard.SpaceW);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/SpaceH", ref _Theme.SongMenuTileBoard.SpaceH);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumW", ref _Theme.SongMenuTileBoard.NumW);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumH", ref _Theme.SongMenuTileBoard.NumH);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/SpaceW", ref _Theme.SongMenuTileBoard.SpaceW);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/SpaceH", ref _Theme.SongMenuTileBoard.SpaceH);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumWsmall", ref _Theme.SongMenuTileBoard.NumWsmall);
_ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumHsmall", ref _Theme.SongMenuTileBoard.NumHsmall);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumWsmall", ref _Theme.SongMenuTileBoard.NumWsmall);
ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuTileBoard/NumHsmall", ref _Theme.SongMenuTileBoard.NumHsmall);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectX", ref _Theme.SongMenuTileBoard.TileRect.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectY", ref _Theme.SongMenuTileBoard.TileRect.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectZ", ref _Theme.SongMenuTileBoard.TileRect.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectW", ref _Theme.SongMenuTileBoard.TileRect.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectH", ref _Theme.SongMenuTileBoard.TileRect.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectX", ref _Theme.SongMenuTileBoard.TileRect.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectY", ref _Theme.SongMenuTileBoard.TileRect.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectZ", ref _Theme.SongMenuTileBoard.TileRect.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectW", ref _Theme.SongMenuTileBoard.TileRect.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectH", ref _Theme.SongMenuTileBoard.TileRect.H);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallX", ref _Theme.SongMenuTileBoard.TileRectSmall.X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallY", ref _Theme.SongMenuTileBoard.TileRectSmall.Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallZ", ref _Theme.SongMenuTileBoard.TileRectSmall.Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallW", ref _Theme.SongMenuTileBoard.TileRectSmall.W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallH", ref _Theme.SongMenuTileBoard.TileRectSmall.H);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallX", ref _Theme.SongMenuTileBoard.TileRectSmall.X);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallY", ref _Theme.SongMenuTileBoard.TileRectSmall.Y);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallZ", ref _Theme.SongMenuTileBoard.TileRectSmall.Z);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallW", ref _Theme.SongMenuTileBoard.TileRectSmall.W);
ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallH", ref _Theme.SongMenuTileBoard.TileRectSmall.H);
#endregion SongMenuTileBoard
if (_ThemeLoaded)
if (ThemeLoaded)
{
_Theme.Name = elementName;
@@ -227,7 +223,7 @@ namespace VocaluxeLib.Menu.SongMenu
Init();
}
return _ThemeLoaded;
return ThemeLoaded;
}
#endregion Theme
+56 -43
View File
@@ -59,6 +59,8 @@ namespace VocaluxeLib.Menu.SongMenu
private bool _MouseWasInRect;
private readonly List<IMenuElement> _SubElements = new List<IMenuElement>();
public override float SelectedTileZoomFactor
{
get { return 1.2f; }
@@ -77,15 +79,6 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
private void _UpdateTileSelection()
{
foreach (CStatic tile in _Tiles)
tile.Selected = false;
int tileNr = _SelectionNr - _Offset;
if (tileNr >= 0 && tileNr < _Tiles.Count)
_Tiles[tileNr].Selected = true;
}
public override bool SmallView
{
set
@@ -99,12 +92,6 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
public CSongMenuTileBoard(int partyModeID)
: base(partyModeID) {}
public CSongMenuTileBoard(SThemeSongMenu theme, int partyModeID)
: base(theme, partyModeID) {}
protected override int _PreviewNr
{
set
@@ -120,6 +107,31 @@ namespace VocaluxeLib.Menu.SongMenu
}
}
public CSongMenuTileBoard(int partyModeID) : base(partyModeID) {}
public CSongMenuTileBoard(SThemeSongMenu theme, int partyModeID) : base(theme, partyModeID)
{
_Artist = new CText(_Theme.SongMenuTileBoard.TextArtist, _PartyModeID);
_Title = new CText(_Theme.SongMenuTileBoard.TextTitle, _PartyModeID);
_SongLength = new CText(_Theme.SongMenuTileBoard.TextSongLength, _PartyModeID);
_CoverBig = new CStatic(_Theme.SongMenuTileBoard.StaticCoverBig, _PartyModeID);
_TextBG = new CStatic(_Theme.SongMenuTileBoard.StaticTextBG, _PartyModeID);
_DuetIcon = new CStatic(_Theme.SongMenuTileBoard.StaticDuetIcon, _PartyModeID);
_VideoIcon = new CStatic(_Theme.SongMenuTileBoard.StaticVideoIcon, _PartyModeID);
_MedleyCalcIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyCalcIcon, _PartyModeID);
_MedleyTagIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyTagIcon, _PartyModeID);
_SubElements.AddRange(new IMenuElement[] {_Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon});
}
private void _UpdateTileSelection()
{
foreach (CStatic tile in _Tiles)
tile.Selected = false;
int tileNr = _SelectionNr - _Offset;
if (tileNr >= 0 && tileNr < _Tiles.Count)
_Tiles[tileNr].Selected = true;
}
public override bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
{
string item = xmlPath + "/" + elementName;
@@ -143,16 +155,9 @@ namespace VocaluxeLib.Menu.SongMenu
{
_Theme.Name = elementName;
_Theme.SongMenuTileBoard.TextArtist = _Artist.GetTheme();
_Theme.SongMenuTileBoard.TextSongLength = _SongLength.GetTheme();
_Theme.SongMenuTileBoard.TextTitle = _Title.GetTheme();
_Theme.SongMenuTileBoard.StaticCoverBig = _CoverBig.GetTheme();
_Theme.SongMenuTileBoard.StaticDuetIcon = _DuetIcon.GetTheme();
_Theme.SongMenuTileBoard.StaticMedleyCalcIcon = _MedleyCalcIcon.GetTheme();
_Theme.SongMenuTileBoard.StaticMedleyTagIcon = _MedleyTagIcon.GetTheme();
_Theme.SongMenuTileBoard.StaticTextBG = _TextBG.GetTheme();
_Theme.SongMenuTileBoard.StaticVideoIcon = _VideoIcon.GetTheme();
_ReadSubTheme();
_SubElements.Clear();
_SubElements.AddRange(new IMenuElement[] {_Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon});
LoadSkin();
Init();
}
@@ -160,6 +165,25 @@ namespace VocaluxeLib.Menu.SongMenu
return themeLoaded;
}
private void _ReadSubTheme()
{
_Theme.SongMenuTileBoard.TextArtist = (SThemeText)_Artist.GetTheme();
_Theme.SongMenuTileBoard.TextSongLength = (SThemeText)_SongLength.GetTheme();
_Theme.SongMenuTileBoard.TextTitle = (SThemeText)_Title.GetTheme();
_Theme.SongMenuTileBoard.StaticCoverBig = (SThemeStatic)_CoverBig.GetTheme();
_Theme.SongMenuTileBoard.StaticDuetIcon = (SThemeStatic)_DuetIcon.GetTheme();
_Theme.SongMenuTileBoard.StaticMedleyCalcIcon = (SThemeStatic)_MedleyCalcIcon.GetTheme();
_Theme.SongMenuTileBoard.StaticMedleyTagIcon = (SThemeStatic)_MedleyTagIcon.GetTheme();
_Theme.SongMenuTileBoard.StaticTextBG = (SThemeStatic)_TextBG.GetTheme();
_Theme.SongMenuTileBoard.StaticVideoIcon = (SThemeStatic)_VideoIcon.GetTheme();
}
public override object GetTheme()
{
_ReadSubTheme();
return base.GetTheme();
}
public override void Init()
{
base.Init();
@@ -504,14 +528,8 @@ namespace VocaluxeLib.Menu.SongMenu
else
_CoverBig.Draw(EAspect.Crop);
_Artist.Draw();
_Title.Draw();
_SongLength.Draw();
_DuetIcon.Draw();
_VideoIcon.Draw();
_MedleyCalcIcon.Draw();
_MedleyTagIcon.Draw();
foreach (IMenuElement element in _SubElements)
element.Draw();
}
public override CStatic GetSelectedSongCover()
@@ -611,16 +629,11 @@ namespace VocaluxeLib.Menu.SongMenu
public override void LoadSkin()
{
base.LoadSkin();
_Artist = new CText(_Theme.SongMenuTileBoard.TextArtist, _PartyModeID);
_Title = new CText(_Theme.SongMenuTileBoard.TextTitle, _PartyModeID);
_SongLength = new CText(_Theme.SongMenuTileBoard.TextSongLength, _PartyModeID);
_CoverBig = new CStatic(_Theme.SongMenuTileBoard.StaticCoverBig, _PartyModeID);
_TextBG = new CStatic(_Theme.SongMenuTileBoard.StaticTextBG, _PartyModeID);
_DuetIcon = new CStatic(_Theme.SongMenuTileBoard.StaticDuetIcon, _PartyModeID);
_VideoIcon = new CStatic(_Theme.SongMenuTileBoard.StaticVideoIcon, _PartyModeID);
_MedleyCalcIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyCalcIcon, _PartyModeID);
_MedleyTagIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyTagIcon, _PartyModeID);
foreach (IThemeable themeable in _SubElements.OfType<IThemeable>())
themeable.LoadSkin();
// Those are drawn seperately so they are not in the above list
_CoverBig.LoadSkin();
_TextBG.LoadSkin();
Init();
}
-3
View File
@@ -45,8 +45,5 @@ namespace VocaluxeLib.Menu.SongMenu
int GetPreviewSong();
bool SmallView { get; set; }
bool ThemeLoaded { get; }
SThemeSongMenu GetTheme();
}
}
+7 -2
View File
@@ -23,17 +23,22 @@ namespace VocaluxeLib.PartyModes
public abstract class CPartyMode : IPartyMode
{
private readonly string _Folder;
public int ID { get; private set; }
private readonly int _ID;
protected SScreenSongOptions _ScreenSongOptions = new SScreenSongOptions {Selection = new SSelectionOptions(), Sorting = new SSortingOptions()};
protected readonly Dictionary<string, CMenuParty> _Screens = new Dictionary<string, CMenuParty>();
protected CPartyMode(int id, string folder)
{
ID = id;
_ID = id;
_Folder = folder;
}
#region Implementation
public int ID
{
get { return _ID; }
}
public abstract bool Init();
public void LoadTheme()
+1 -2
View File
@@ -23,8 +23,7 @@ namespace VocaluxeLib.PartyModes
public class CPartyModeNone : CPartyMode
{
//just a dummy for normal game mode
public CPartyModeNone(int id, string folder)
: base(id, folder)
public CPartyModeNone(int id, string folder) : base(id, folder)
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = false;
+2
View File
@@ -416,7 +416,9 @@ namespace VocaluxeLib.Songs
{
//PreviewStart is not set or <=0
_Song.Preview.StartTime = (headerFlags & EHeaderFlags.MedleyStartBeat) != 0 ? CBase.Game.GetTimeFromBeats(_Song.Medley.StartBeat, _Song.BPM) : 0f;
// ReSharper disable CompareOfFloatsByEqualityOperator
_Song.Preview.Source = _Song.Preview.StartTime == 0 ? EDataSource.None : EDataSource.Calculated;
// ReSharper restore CompareOfFloatsByEqualityOperator
}
if ((headerFlags & EHeaderFlags.MedleyStartBeat) != 0 && (headerFlags & EHeaderFlags.MedleyEndBeat) != 0)
+5 -2
View File
@@ -1,10 +1,10 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Allgemeine Informationen über eine Assembly werden über folgende
// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
// die einer Assembly zugeordnet sind.
[assembly: AssemblyTitle("VocaluxeTests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
@@ -17,9 +17,11 @@ using System.Runtime.InteropServices;
// Wenn ComVisible auf "false" festgelegt wird, sind die Typen innerhalb dieser Assembly
// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von
// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen.
[assembly: ComVisible(false)]
// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
[assembly: Guid("3bdc6da5-a651-452e-903c-deec310288ad")]
// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
@@ -32,5 +34,6 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// durch Einsatz von '*', wie in nachfolgendem Beispiel:
// [Assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+3 -8
View File
@@ -498,8 +498,7 @@ namespace WebserverInitalConfig
{
if (String.IsNullOrEmpty(networkURL))
throw new ArgumentNullException("networkURL");
HTTP_SERVICE_CONFIG_URLACL_SET res = new HTTP_SERVICE_CONFIG_URLACL_SET();
res.KeyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY("");
HTTP_SERVICE_CONFIG_URLACL_SET res = new HTTP_SERVICE_CONFIG_URLACL_SET {KeyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY("")};
CallHttpApi(
delegate
{
@@ -539,9 +538,7 @@ namespace WebserverInitalConfig
ThrowWin32ExceptionIfError(retVal);
res = (HTTP_SERVICE_CONFIG_URLACL_SET)Marshal.PtrToStructure(pOutputConfigInfo, typeof(HTTP_SERVICE_CONFIG_URLACL_SET));
}
else if (ERROR_FILE_NOT_FOUND == retVal)
return;
else
else if (ERROR_FILE_NOT_FOUND != retVal)
ThrowWin32ExceptionIfError(retVal);
}
finally
@@ -604,9 +601,7 @@ namespace WebserverInitalConfig
HTTP_SERVICE_CONFIG_URLACL_KEY keyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL);
HTTP_SERVICE_CONFIG_URLACL_PARAM paramDesc = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);
HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET();
inputConfigInfoSet.KeyDesc = keyDesc;
inputConfigInfoSet.ParamDesc = paramDesc;
HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET {KeyDesc = keyDesc, ParamDesc = paramDesc};
IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false);