Move Equalizer-Element to Screen-Files. Still some work left.
This commit is contained in:
1 parent
65b76df0f7
commit
2484c52e08
5 files changed
+440
-104
No files matched your search
@@ -0,0 +1,324 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using System.Xml;
|
||||
using System.Xml.XPath;
|
||||
|
||||
using Vocaluxe.Base;
|
||||
using Vocaluxe.Lib.Draw;
|
||||
|
||||
namespace Vocaluxe.Menu
|
||||
{
|
||||
enum EEqualizerStyle
|
||||
{
|
||||
Bars,
|
||||
Collums
|
||||
}
|
||||
|
||||
struct SThemeEqualizer
|
||||
{
|
||||
public string Name;
|
||||
|
||||
public string ColorName;
|
||||
public string MaxColorName;
|
||||
public string TextureName;
|
||||
|
||||
public int NumBars;
|
||||
|
||||
public EEqualizerStyle Style;
|
||||
public EOffOn DrawNegative;
|
||||
}
|
||||
|
||||
class CEqualizer : IMenuElement
|
||||
{
|
||||
private SThemeEqualizer _Theme;
|
||||
private bool _ThemeLoaded;
|
||||
|
||||
public SRectF Rect;
|
||||
public SColorF Color;
|
||||
public SColorF MaxColor;
|
||||
public float Space;
|
||||
|
||||
public bool Reflection;
|
||||
public float ReflectionSpace;
|
||||
public float ReflectionHeight;
|
||||
|
||||
public bool Selected;
|
||||
public bool Visible;
|
||||
public bool ScreenHandles;
|
||||
|
||||
private float[] _Bars;
|
||||
|
||||
public CEqualizer()
|
||||
{
|
||||
_Theme = new SThemeEqualizer();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
Rect = new SRectF();
|
||||
Color = new SColorF();
|
||||
MaxColor = new SColorF();
|
||||
|
||||
Selected = false;
|
||||
Visible = true;
|
||||
ScreenHandles = false;
|
||||
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
}
|
||||
|
||||
public bool LoadTheme(string XmlPath, string ElementName, XPathNavigator navigator, int SkinIndex)
|
||||
{
|
||||
string item = XmlPath + "/" + ElementName;
|
||||
_ThemeLoaded = true;
|
||||
|
||||
_ThemeLoaded &= CHelper.GetValueFromXML(item + "/Skin", navigator, ref _Theme.TextureName, String.Empty);
|
||||
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/X", navigator, ref Rect.X);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Y", navigator, ref Rect.Y);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Z", navigator, ref Rect.Z);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/W", navigator, ref Rect.W);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/H", navigator, ref Rect.H);
|
||||
|
||||
_ThemeLoaded &= CHelper.TryGetIntValueFromXML(item + "/NumBars", navigator, ref _Theme.NumBars);
|
||||
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Space", navigator, ref Space);
|
||||
|
||||
_ThemeLoaded &= CHelper.TryGetEnumValueFromXML<EEqualizerStyle>(item + "/Style", navigator, ref _Theme.Style);
|
||||
|
||||
_ThemeLoaded &= CHelper.TryGetEnumValueFromXML<EOffOn>(item + "/DrawNegative", navigator, ref _Theme.DrawNegative);
|
||||
|
||||
if (CHelper.GetValueFromXML(item + "/Color", navigator, ref _Theme.ColorName, String.Empty))
|
||||
{
|
||||
_ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/R", navigator, ref Color.R);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/G", navigator, ref Color.G);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/B", navigator, ref Color.B);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/A", navigator, ref Color.A);
|
||||
}
|
||||
|
||||
if (CHelper.GetValueFromXML(item + "/MaxColor", navigator, ref _Theme.MaxColorName, String.Empty))
|
||||
{
|
||||
_ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref Color);
|
||||
}
|
||||
else
|
||||
{
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/MaxR", navigator, ref MaxColor.R);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/MaxG", navigator, ref MaxColor.G);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/MaxB", navigator, ref MaxColor.B);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/MaxA", navigator, ref MaxColor.A);
|
||||
}
|
||||
|
||||
//Reflection
|
||||
if (CHelper.ItemExistsInXML(item + "/Reflection", navigator))
|
||||
{
|
||||
Reflection = true;
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Reflection/Space", navigator, ref ReflectionSpace);
|
||||
_ThemeLoaded &= CHelper.TryGetFloatValueFromXML(item + "/Reflection/Height", navigator, ref ReflectionHeight);
|
||||
}
|
||||
else
|
||||
Reflection = false;
|
||||
|
||||
if (_ThemeLoaded)
|
||||
{
|
||||
_Theme.Name = ElementName;
|
||||
_Bars = new float[_Theme.NumBars];
|
||||
LoadTextures();
|
||||
}
|
||||
return _ThemeLoaded;
|
||||
}
|
||||
|
||||
public bool SaveTheme(XmlWriter writer)
|
||||
{
|
||||
if (_ThemeLoaded)
|
||||
{
|
||||
writer.WriteStartElement(_Theme.Name);
|
||||
|
||||
writer.WriteComment("<Skin>: Texture name");
|
||||
writer.WriteElementString("Skin", _Theme.TextureName);
|
||||
|
||||
writer.WriteComment("<X>, <Y>, <Z>, <W>, <H>: Equalizer position, width and height");
|
||||
writer.WriteElementString("X", Rect.X.ToString("#0"));
|
||||
writer.WriteElementString("Y", Rect.Y.ToString("#0"));
|
||||
writer.WriteElementString("Z", Rect.Z.ToString("#0.00"));
|
||||
writer.WriteElementString("W", Rect.W.ToString("#0"));
|
||||
writer.WriteElementString("H", Rect.H.ToString("#0"));
|
||||
|
||||
writer.WriteComment("<NumBars>: Number of equalizer-elements.");
|
||||
writer.WriteElementString("NumBars", _Theme.NumBars.ToString("#0"));
|
||||
writer.WriteComment("<Space>: Space between equalizer-elements.");
|
||||
writer.WriteElementString("Space", Space.ToString("#0.00"));
|
||||
writer.WriteComment("<Style>: Style of equalizer-elements: " + CConfig.ListStrings(Enum.GetNames(typeof(EEqualizerStyle))));
|
||||
writer.WriteElementString("Style", Enum.GetName(typeof(EEqualizerStyle), _Theme.Style));
|
||||
writer.WriteComment("<DrawNegative>: Draw negative values: " + CConfig.ListStrings(Enum.GetNames(typeof(EOffOn))));
|
||||
writer.WriteElementString("Style", Enum.GetName(typeof(EOffOn), _Theme.DrawNegative));
|
||||
|
||||
writer.WriteComment("<Color>: Equalizer color from ColorScheme (high priority)");
|
||||
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
|
||||
if (_Theme.ColorName != String.Empty)
|
||||
{
|
||||
writer.WriteElementString("Color", _Theme.ColorName);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("R", Color.R.ToString("#0.00"));
|
||||
writer.WriteElementString("G", Color.G.ToString("#0.00"));
|
||||
writer.WriteElementString("B", Color.B.ToString("#0.00"));
|
||||
writer.WriteElementString("A", Color.A.ToString("#0.00"));
|
||||
}
|
||||
writer.WriteComment("<Color>: Equalizer color from ColorScheme (high priority)");
|
||||
writer.WriteComment("or <R>, <G>, <B>, <A> (lower priority)");
|
||||
if (_Theme.ColorName != String.Empty)
|
||||
{
|
||||
writer.WriteElementString("Color", _Theme.ColorName);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.WriteElementString("R", Color.R.ToString("#0.00"));
|
||||
writer.WriteElementString("G", Color.G.ToString("#0.00"));
|
||||
writer.WriteElementString("B", Color.B.ToString("#0.00"));
|
||||
writer.WriteElementString("A", Color.A.ToString("#0.00"));
|
||||
}
|
||||
|
||||
writer.WriteComment("<Reflection> If exists:");
|
||||
writer.WriteComment(" <Space>: Reflection Space");
|
||||
writer.WriteComment(" <Height>: Reflection Height");
|
||||
if (Reflection)
|
||||
{
|
||||
writer.WriteStartElement("Reflection");
|
||||
writer.WriteElementString("Space", ReflectionSpace.ToString("#0"));
|
||||
writer.WriteElementString("Height", ReflectionHeight.ToString("#0"));
|
||||
writer.WriteEndElement();
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void Update(float[] weights)
|
||||
{
|
||||
if (weights == null || weights.Length == 0 || _Bars == null)
|
||||
return;
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
|
||||
if (weights.Length > i){
|
||||
_Bars[i] = weights[i];
|
||||
if (_Theme.DrawNegative == EOffOn.TR_CONFIG_OFF && weights[i] < 0)
|
||||
_Bars[i] = 0f;
|
||||
}
|
||||
else
|
||||
_Bars[i] = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (_Bars == null || _Bars.Length == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
_Bars[i] = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (_Bars == null)
|
||||
return;
|
||||
|
||||
float dx = Rect.W / _Bars.Length + Space;
|
||||
int max = _Bars.Length - 1;
|
||||
float maxB = _Bars[max];
|
||||
for (int i = 0; i < _Bars.Length - 1; i++)
|
||||
{
|
||||
if (_Bars[i] > maxB)
|
||||
{
|
||||
maxB = _Bars[i];
|
||||
max = i;
|
||||
}
|
||||
}
|
||||
|
||||
switch (_Theme.Style){
|
||||
case EEqualizerStyle.Collums:
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
SRectF bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z);
|
||||
SColorF color = Color;
|
||||
if (i == max)
|
||||
{
|
||||
color = MaxColor;
|
||||
}
|
||||
|
||||
CDraw.DrawColor(color, bar);
|
||||
|
||||
if (Reflection)
|
||||
CDraw.DrawColorReflection(color, bar, ReflectionSpace, ReflectionHeight);
|
||||
}
|
||||
break;
|
||||
|
||||
case EEqualizerStyle.Bars:
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
SRectF bar = new SRectF(Rect.X + dx * i, Rect.Y + Rect.H - _Bars[i] * Rect.H, dx - Space, _Bars[i] * Rect.H, Rect.Z);
|
||||
SColorF color = Color;
|
||||
if (i == max)
|
||||
{
|
||||
color = MaxColor;
|
||||
}
|
||||
|
||||
CDraw.DrawColor(color, bar);
|
||||
|
||||
if (Reflection)
|
||||
CDraw.DrawColorReflection(color, bar, ReflectionSpace, ReflectionHeight);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void UnloadTextures()
|
||||
{
|
||||
}
|
||||
|
||||
public void LoadTextures()
|
||||
{
|
||||
if (_Theme.ColorName != String.Empty)
|
||||
Color = CTheme.GetColor(_Theme.ColorName);
|
||||
|
||||
if (_Theme.MaxColorName != String.Empty)
|
||||
MaxColor = CTheme.GetColor(_Theme.MaxColorName);
|
||||
}
|
||||
|
||||
public void ReloadTextures()
|
||||
{
|
||||
UnloadTextures();
|
||||
LoadTextures();
|
||||
}
|
||||
|
||||
#region ThemeEdit
|
||||
public void MoveElement(int stepX, int stepY)
|
||||
{
|
||||
Rect.X += stepX;
|
||||
Rect.Y += stepY;
|
||||
}
|
||||
|
||||
public void ResizeElement(int stepW, int stepH)
|
||||
{
|
||||
Rect.W += stepW;
|
||||
if (Rect.W <= 0)
|
||||
Rect.W = 1;
|
||||
|
||||
Rect.H += stepH;
|
||||
if (Rect.H <= 0)
|
||||
Rect.H = 1;
|
||||
}
|
||||
#endregion ThemeEdit
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,8 @@ namespace Vocaluxe.Menu
|
||||
TSongMenu,
|
||||
TLyric,
|
||||
TSingNote,
|
||||
TNameSelection
|
||||
TNameSelection,
|
||||
TEqualizer
|
||||
}
|
||||
|
||||
class CInteraction
|
||||
|
||||
+101
-1
@@ -36,6 +36,7 @@ namespace Vocaluxe.Menu
|
||||
private List<CLyric> _Lyrics;
|
||||
private List<CSingNotes> _SingNotes;
|
||||
private List<CNameSelection> _NameSelections;
|
||||
private List<CEqualizer> _Equalizers;
|
||||
|
||||
private Hashtable _htBackgrounds;
|
||||
private Hashtable _htStatics;
|
||||
@@ -46,6 +47,7 @@ namespace Vocaluxe.Menu
|
||||
private Hashtable _htSelectSlides;
|
||||
private Hashtable _htSingNotes;
|
||||
private Hashtable _htNameSelections;
|
||||
private Hashtable _htEqualizers;
|
||||
|
||||
|
||||
private int _PrevMouseX;
|
||||
@@ -67,6 +69,7 @@ namespace Vocaluxe.Menu
|
||||
protected string[] _ThemeSelectSlides;
|
||||
protected string[] _ThemeSingNotes;
|
||||
protected string[] _ThemeNameSelections;
|
||||
protected string[] _ThemeEqualizers;
|
||||
|
||||
protected SRectF _ScreenArea;
|
||||
|
||||
@@ -99,6 +102,7 @@ namespace Vocaluxe.Menu
|
||||
_Lyrics = new List<CLyric>();
|
||||
_SingNotes = new List<CSingNotes>();
|
||||
_NameSelections = new List<CNameSelection>();
|
||||
_Equalizers = new List<CEqualizer>();
|
||||
|
||||
_htBackgrounds = new Hashtable();
|
||||
_htStatics = new Hashtable();
|
||||
@@ -109,6 +113,7 @@ namespace Vocaluxe.Menu
|
||||
_htSelectSlides = new Hashtable();
|
||||
_htSingNotes = new Hashtable();
|
||||
_htNameSelections = new Hashtable();
|
||||
_htEqualizers = new Hashtable();
|
||||
|
||||
_PrevMouseX = 0;
|
||||
_PrevMouseY = 0;
|
||||
@@ -129,6 +134,7 @@ namespace Vocaluxe.Menu
|
||||
_ThemeSelectSlides = null;
|
||||
_ThemeSingNotes = null;
|
||||
_ThemeNameSelections = null;
|
||||
_ThemeEqualizers = null;
|
||||
|
||||
}
|
||||
#region ThemeHandler
|
||||
@@ -311,6 +317,22 @@ namespace Vocaluxe.Menu
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (_ThemeEqualizers != null)
|
||||
{
|
||||
for (int i = 0; i < _ThemeEqualizers.Length; i++)
|
||||
{
|
||||
CEqualizer eq = new CEqualizer();
|
||||
if (eq.LoadTheme("//root/" + _ThemeName, _ThemeEqualizers[i], navigator, SkinIndex))
|
||||
{
|
||||
_htEqualizers.Add(_ThemeEqualizers[i], AddEqualizer(eq));
|
||||
}
|
||||
else
|
||||
{
|
||||
CLog.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -386,6 +408,12 @@ namespace Vocaluxe.Menu
|
||||
_NameSelections[i].SaveTheme(writer);
|
||||
}
|
||||
|
||||
//Equalizers
|
||||
for (int i = 0; i < _Equalizers.Count; i++)
|
||||
{
|
||||
_Equalizers[i].SaveTheme(writer);
|
||||
}
|
||||
|
||||
writer.WriteEndElement();
|
||||
|
||||
// End of File
|
||||
@@ -442,6 +470,11 @@ namespace Vocaluxe.Menu
|
||||
{
|
||||
ns.ReloadTextures();
|
||||
}
|
||||
|
||||
foreach (CEqualizer eq in _Equalizers)
|
||||
{
|
||||
eq.ReloadTextures();
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void UnloadTextures()
|
||||
@@ -491,6 +524,10 @@ namespace Vocaluxe.Menu
|
||||
ns.UnloadTextures();
|
||||
}
|
||||
|
||||
foreach (CEqualizer eq in _Equalizers)
|
||||
{
|
||||
eq.UnloadTextures();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -547,6 +584,11 @@ namespace Vocaluxe.Menu
|
||||
{
|
||||
return _NameSelections;
|
||||
}
|
||||
|
||||
public List<CEqualizer> GetEqualizers()
|
||||
{
|
||||
return _Equalizers;
|
||||
}
|
||||
#endregion GetLists
|
||||
|
||||
#region ElementHandler
|
||||
@@ -622,6 +664,14 @@ namespace Vocaluxe.Menu
|
||||
return _NameSelections.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
public CEqualizer[] Equalizers
|
||||
{
|
||||
get
|
||||
{
|
||||
return _Equalizers.ToArray();
|
||||
}
|
||||
}
|
||||
#endregion Get Arrays
|
||||
|
||||
#region Hashtables
|
||||
@@ -741,6 +791,19 @@ namespace Vocaluxe.Menu
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public int htEqualizer(string key)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (int)_htEqualizers[key];
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
CLog.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
#endregion Hashtables
|
||||
#endregion ElementHandler
|
||||
|
||||
@@ -999,7 +1062,8 @@ namespace Vocaluxe.Menu
|
||||
_Interactions[i].Type == EType.TStatic ||
|
||||
_Interactions[i].Type == EType.TNameSelection ||
|
||||
_Interactions[i].Type == EType.TText ||
|
||||
_Interactions[i].Type == EType.TSongMenu))
|
||||
_Interactions[i].Type == EType.TSongMenu ||
|
||||
_Interactions[i].Type == EType.TEqualizer))
|
||||
{
|
||||
ZSort zs = new ZSort();
|
||||
zs.ID = i;
|
||||
@@ -1085,6 +1149,13 @@ namespace Vocaluxe.Menu
|
||||
_AddInteraction(_NameSelections.Count - 1, EType.TNameSelection);
|
||||
return _NameSelections.Count - 1;
|
||||
}
|
||||
|
||||
public int AddEqualizer(CEqualizer eq)
|
||||
{
|
||||
_Equalizers.Add(eq);
|
||||
_AddInteraction(_Equalizers.Count - 1, EType.TEqualizer);
|
||||
return _Equalizers.Count - 1;
|
||||
}
|
||||
#endregion Elements
|
||||
|
||||
#region InteractionHandling
|
||||
@@ -1233,6 +1304,10 @@ namespace Vocaluxe.Menu
|
||||
if (CHelper.IsInBounds(_NameSelections[interact.Num].Rect, x, y))
|
||||
return true;
|
||||
break;
|
||||
case EType.TEqualizer:
|
||||
if (CHelper.IsInBounds(_Equalizers[interact.Num].Rect, x, y))
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1255,6 +1330,8 @@ namespace Vocaluxe.Menu
|
||||
return _Lyrics[interact.Num].Rect.Z;
|
||||
case EType.TNameSelection:
|
||||
return _NameSelections[interact.Num].Rect.Z;
|
||||
case EType.TEqualizer:
|
||||
return _Equalizers[interact.Num].Rect.Z;
|
||||
}
|
||||
return CSettings.zFar;
|
||||
}
|
||||
@@ -1283,6 +1360,9 @@ namespace Vocaluxe.Menu
|
||||
|
||||
case EType.TNameSelection:
|
||||
return _NameSelections[_Interactions[interaction].Num].Rect.Z;
|
||||
|
||||
case EType.TEqualizer:
|
||||
return _Equalizers[_Interactions[interaction].Num].Rect.Z;
|
||||
}
|
||||
|
||||
return CSettings.zFar;
|
||||
@@ -1605,6 +1685,9 @@ namespace Vocaluxe.Menu
|
||||
case EType.TNameSelection:
|
||||
_NameSelections[_Interactions[_Selection].Num].Selected = true;
|
||||
break;
|
||||
case EType.TEqualizer:
|
||||
_Equalizers[_Interactions[_Selection].Num].Selected = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1633,6 +1716,9 @@ namespace Vocaluxe.Menu
|
||||
case EType.TNameSelection:
|
||||
_NameSelections[_Interactions[_Selection].Num].Selected = false;
|
||||
break;
|
||||
case EType.TEqualizer:
|
||||
_Equalizers[_Interactions[_Selection].Num].Selected = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1744,6 +1830,9 @@ namespace Vocaluxe.Menu
|
||||
|
||||
case EType.TNameSelection:
|
||||
return _NameSelections[_Interactions[interaction].Num].Visible;
|
||||
|
||||
case EType.TEqualizer:
|
||||
return _Equalizers[_Interactions[interaction].Num].Visible;
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -1774,6 +1863,9 @@ namespace Vocaluxe.Menu
|
||||
|
||||
case EType.TNameSelection:
|
||||
return _NameSelections[_Interactions[interaction].Num].Rect;
|
||||
|
||||
case EType.TEqualizer:
|
||||
return _Equalizers[_Interactions[interaction].Num].Rect;
|
||||
}
|
||||
|
||||
return Result;
|
||||
@@ -1815,6 +1907,14 @@ namespace Vocaluxe.Menu
|
||||
case EType.TNameSelection:
|
||||
_NameSelections[_Interactions[interaction].Num].Draw();
|
||||
break;
|
||||
|
||||
case EType.TEqualizer:
|
||||
if (!_Equalizers[_Interactions[interaction].Num].ScreenHandles)
|
||||
{
|
||||
//_Equalizers[_Interactions[interaction].Num].Update(CSound.Get
|
||||
//_Equalizers[_Interactions[interaction].Num].Draw();
|
||||
}
|
||||
break;
|
||||
|
||||
//TODO:
|
||||
//case EType.TLyric:
|
||||
|
||||
@@ -40,6 +40,9 @@ namespace Vocaluxe.Screens
|
||||
private const string TextDelayChannel1 = "TextDelayChannel1";
|
||||
private const string TextDelayChannel2 = "TextDelayChannel2";
|
||||
|
||||
private const string EqualizerChannel1 = "EqualizerChannel1";
|
||||
private const string EqualizerChannel2 = "EqualizerChannel2";
|
||||
|
||||
private readonly string[] StaticEnergyChannel = new string[] { "StaticEnergyChannel1", "StaticEnergyChannel2" };
|
||||
private float[] ChannelEnergy;
|
||||
|
||||
@@ -51,8 +54,6 @@ namespace Vocaluxe.Screens
|
||||
private bool _DelayTestRunning;
|
||||
private int _DelaySound;
|
||||
|
||||
private Equalizer[] _Equalizer;
|
||||
|
||||
public CScreenOptionsRecord()
|
||||
{
|
||||
Init();
|
||||
@@ -73,6 +74,7 @@ namespace Vocaluxe.Screens
|
||||
_ThemeTexts = new string[] { TextWarning, TextDelayChannel1, TextDelayChannel2 };
|
||||
_ThemeButtons = new string[] { ButtonExit, ButtonDelayTest };
|
||||
_ThemeSelectSlides = new string[] { SelectSlideRecordDevices, SelectSlideRecordInputs, SelectSlideRecordChannel1, SelectSlideRecordChannel2, SelectSlideDelay };
|
||||
_ThemeEqualizers = new string[] { EqualizerChannel1, EqualizerChannel2 };
|
||||
}
|
||||
|
||||
public override void LoadTheme()
|
||||
@@ -277,28 +279,29 @@ namespace Vocaluxe.Screens
|
||||
if (player > 0)
|
||||
{
|
||||
ChannelEnergy[0] = CSound.RecordGetMaxVolume(player - 1);
|
||||
_Equalizer[0].Update(CSound.ToneWeigth(player - 1));
|
||||
Equalizers[htEqualizer(EqualizerChannel1)].Update(CSound.ToneWeigth(player - 1));
|
||||
}
|
||||
else
|
||||
_Equalizer[0].Reset();
|
||||
Equalizers[htEqualizer(EqualizerChannel1)].Reset();
|
||||
|
||||
ChannelEnergy[1] = 0f;
|
||||
player = SelectSlides[htSelectSlides(SelectSlideRecordChannel2)].Selection;
|
||||
if (player > 0)
|
||||
{
|
||||
ChannelEnergy[1] = CSound.RecordGetMaxVolume(player - 1);
|
||||
_Equalizer[1].Update(CSound.ToneWeigth(player - 1));
|
||||
Equalizers[htEqualizer(EqualizerChannel2)].Update(CSound.ToneWeigth(player - 1));
|
||||
}
|
||||
else
|
||||
_Equalizer[1].Reset();
|
||||
Equalizers[htEqualizer(EqualizerChannel2)].Reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < ChannelEnergy.Length; i++)
|
||||
{
|
||||
ChannelEnergy[i] = 0f;
|
||||
_Equalizer[i].Reset();
|
||||
}
|
||||
Equalizers[htEqualizer(EqualizerChannel1)].Reset();
|
||||
Equalizers[htEqualizer(EqualizerChannel2)].Reset();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -361,13 +364,6 @@ namespace Vocaluxe.Screens
|
||||
|
||||
_DelayTestRunning = false;
|
||||
_DelaySound = -1;
|
||||
|
||||
_Equalizer = new Equalizer[2];
|
||||
|
||||
for (int i = 0; i < _Equalizer.Length; i++)
|
||||
{
|
||||
_Equalizer[i] = new Equalizer(new SRectF(50 + 350 * i, 400, 230, 150, -1), CSound.NumHalfTones(0), 2);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnShowFinish()
|
||||
@@ -406,10 +402,8 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < _Equalizer.Length; i++)
|
||||
{
|
||||
_Equalizer[i].Draw();
|
||||
}
|
||||
Equalizers[htEqualizer(EqualizerChannel1)].Draw();
|
||||
Equalizers[htEqualizer(EqualizerChannel2)].Draw();
|
||||
|
||||
DrawFG();
|
||||
|
||||
@@ -594,88 +588,4 @@ namespace Vocaluxe.Screens
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Equalizer
|
||||
{
|
||||
|
||||
private SRectF _Bounds;
|
||||
private float _Space;
|
||||
|
||||
private float[] _Bars;
|
||||
|
||||
public Equalizer(SRectF bounds, int numBars, float space)
|
||||
{
|
||||
_Bounds = bounds;
|
||||
_Space = space;
|
||||
|
||||
if (numBars > 0)
|
||||
_Bars = new float[numBars];
|
||||
}
|
||||
|
||||
public void Update(float[] weights)
|
||||
{
|
||||
if (weights == null || weights.Length == 0 || _Bars == null)
|
||||
return;
|
||||
|
||||
if (_Bars.Length < weights.Length)
|
||||
{
|
||||
}
|
||||
else if (_Bars.Length > weights.Length)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
//if (weights[i] > 0)
|
||||
_Bars[i] = weights[i];
|
||||
//else
|
||||
// _Bars[i] = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset()
|
||||
{
|
||||
if (_Bars == null || _Bars.Length == 0)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
_Bars[i] = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
if (_Bars == null)
|
||||
return;
|
||||
|
||||
float dx = _Bounds.W / _Bars.Length + _Space;
|
||||
int max = _Bars.Length - 1;
|
||||
float maxB = _Bars[max];
|
||||
for (int i = 0; i < _Bars.Length - 1; i++)
|
||||
{
|
||||
if (_Bars[i] > maxB)
|
||||
{
|
||||
maxB = _Bars[i];
|
||||
max = i;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < _Bars.Length; i++)
|
||||
{
|
||||
SRectF bar = new SRectF(_Bounds.X + dx * i, _Bounds.Y + _Bounds.H - _Bars[i] * _Bounds.H, dx - _Space, _Bars[i] * _Bounds.H, _Bounds.Z);
|
||||
SColorF color = new SColorF(1f, 1f, 1f, 1f);
|
||||
if (i == max)
|
||||
{
|
||||
color.B = 0f;
|
||||
color.G = 0f;
|
||||
}
|
||||
|
||||
CDraw.DrawColor(color, bar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,6 +207,7 @@
|
||||
<Compile Include="Lib\Video\IVideoDecoder.cs" />
|
||||
<Compile Include="Menu\CBackground.cs" />
|
||||
<Compile Include="Menu\CButton.cs" />
|
||||
<Compile Include="Menu\CEqualizer.cs" />
|
||||
<Compile Include="Menu\CGraphics.cs" />
|
||||
<Compile Include="Menu\CNameSelection.cs" />
|
||||
<Compile Include="Menu\CLyric.cs" />
|
||||
|
||||
Reference in new issue
Block a user