Merge remote-tracking branch 'upstream/develop' into 6-player

This commit is contained in:
Florian Kuepper committed 2012-04-09 11:07:22 +02:00
commit df0688d563
21 files changed
+309 -188

No files matched your search

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+16 -4
View File
@@ -22,8 +22,14 @@ namespace Vocaluxe.Base
{
if (_LogFile != null)
{
_LogFile.Flush();
_LogFile.Close();
try
{
_LogFile.Flush();
_LogFile.Close();
}
catch (Exception)
{
}
}
}
@@ -32,8 +38,14 @@ namespace Vocaluxe.Base
if (_LogFile == null)
Open();
_LogFile.WriteLine(Text);
_LogFile.Flush();
try
{
_LogFile.WriteLine(Text);
_LogFile.Flush();
}
catch (Exception)
{
}
}
private void Open()
+2 -2
View File
@@ -45,9 +45,9 @@ namespace Vocaluxe.Base
public const int iVersionMajor = 0;
public const int iVersionMinor = 1; // milestones
public const int iVersionSub = 0; // steps
public const ERevision VersionRevision = ERevision.RC;
public const ERevision VersionRevision = ERevision.Alpha;
public const int iBuild = 59; // Increase on every published version! Never Reset!
public const int iBuild = 60; // Increase on every published version! Never Reset!
public const int iDatabaseHighscoreVersion = 1;
public const int iDatabaseCoverVersion = 1;
+32 -1
View File
@@ -4,6 +4,7 @@ using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Song;
@@ -60,6 +61,8 @@ namespace Vocaluxe.Base
private static string _SearchFilter = String.Empty;
private static EOffOn _Tabs = CConfig.Tabs;
private static Thread _CoverLoaderThread = new Thread(new ThreadStart(_LoadCover));
public static string SearchFilter
{
get { return _SearchFilter; }
@@ -849,7 +852,7 @@ namespace Vocaluxe.Base
public static void LoadCover(long WaitTime, int NumLoads)
{
if (CConfig.Renderer != ERenderer.TR_CONFIG_SOFTWARE)
if (CConfig.Renderer == ERenderer.TR_CONFIG_SOFTWARE)
return; //should be removed as soon as the other renderer are ready for queque
if (!SongsLoaded)
@@ -858,6 +861,17 @@ namespace Vocaluxe.Base
if (CoverLoaded)
return;
if (_CoverLoaderThread.ThreadState == System.Threading.ThreadState.Unstarted)
{
_CoverLoaderThread.Name = "CoverLoader";
_CoverLoaderThread.Priority = ThreadPriority.BelowNormal;
_CoverLoaderThread.IsBackground = true;
_CoverLoaderThread.Start();
}
/*
if (!_CoverLoadTimer.IsRunning)
{
_CoverLoadTimer.Reset();
@@ -888,6 +902,23 @@ namespace Vocaluxe.Base
_CoverLoadTimer.Start();
}
}
* */
}
private static void _LoadCover()
{
for (int i = 0; i < _Songs.Count; i++)
{
CSong song = _Songs[i];
song.ReadNotes();
STexture texture = song.CoverTextureSmall;
song.CoverTextureBig = texture;
_CoverLoadIndex++;
}
_CoverLoaded = true;
CDataBase.CommitCovers();
}
}
}
+46 -33
View File
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
@@ -45,7 +46,7 @@ namespace Vocaluxe.Base
public string Path;
public string FileName;
public List<SkinElement> SkinList;
public Dictionary<string, SkinElement> SkinList;
public List<SkinElement> VideoList;
public SColors ThemeColors;
@@ -163,30 +164,49 @@ namespace Vocaluxe.Base
{
string value = String.Empty;
// load skins/textures
for (int i = 0; i < _Skins[index].SkinList.Count; i++)
List<string> keys = new List<string>(_Skins[index].SkinList.Keys);
foreach (string name in keys)
{
CHelper.GetValueFromXML("//root/Skins/" + _Skins[index].SkinList[i].Name, navigator, ref value, String.Empty);
SkinElement sk = new SkinElement();
sk.Name = _Skins[index].SkinList[i].Name;
sk.Value = value;
sk.VideoIndex = -1;
sk.Texture = CDraw.AddTexture(Path.Combine(_Skins[index].Path, sk.Value));
_Skins[index].SkinList[i] = sk;
try
{
CHelper.GetValueFromXML("//root/Skins/" + name, navigator, ref value, String.Empty);
SkinElement sk = _Skins[index].SkinList[name];
sk.Value = value;
sk.VideoIndex = -1;
sk.Texture = CDraw.AddTexture(Path.Combine(_Skins[index].Path, sk.Value));
_Skins[index].SkinList[name] = sk;
}
catch (Exception e)
{
MessageBox.Show("Error on loading texture \"" + name + "\": " + e.Message + e.StackTrace);
CLog.LogError("Error on loading texture \"" + name + "\": " + e.Message + e.StackTrace);
}
}
// load videos
for (int i = 0; i < _Skins[index].VideoList.Count; i++)
{
CHelper.GetValueFromXML("//root/Videos/" + _Skins[index].VideoList[i].Name, navigator, ref value, String.Empty);
SkinElement sk = new SkinElement();
sk.Name = _Skins[index].VideoList[i].Name;
sk.Value = value;
sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[index].Path, sk.Value));
CVideo.VdSetLoop(sk.VideoIndex, true);
CVideo.VdPause(sk.VideoIndex);
sk.Texture = new STexture(-1);
_Skins[index].VideoList[i] = sk;
try
{
CHelper.GetValueFromXML("//root/Videos/" + _Skins[index].VideoList[i].Name, navigator, ref value, String.Empty);
SkinElement sk = new SkinElement();
sk.Name = _Skins[index].VideoList[i].Name;
sk.Value = value;
sk.VideoIndex = CVideo.VdLoad(Path.Combine(_Skins[index].Path, sk.Value));
CVideo.VdSetLoop(sk.VideoIndex, true);
CVideo.VdPause(sk.VideoIndex);
sk.Texture = new STexture(-1);
_Skins[index].VideoList[i] = sk;
}
catch (Exception e)
{
MessageBox.Show("Error on loading video \"" + _Skins[index].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
CLog.LogError("Error on loading video \"" + _Skins[index].VideoList[i].Name + "\": " + e.Message + e.StackTrace);
}
}
// load colors
@@ -199,9 +219,9 @@ namespace Vocaluxe.Base
{
for (int i = 0; i < _Skins.Count; i++)
{
for (int j = 0; j < _Skins[i].SkinList.Count; j++)
foreach (SkinElement sk in _Skins[i].SkinList.Values)
{
STexture Texture = _Skins[i].SkinList[j].Texture;
STexture Texture = sk.Texture;
CDraw.RemoveTexture(ref Texture);
}
@@ -335,7 +355,7 @@ namespace Vocaluxe.Base
#region Skins
writer.WriteStartElement("Skins");
foreach (SkinElement element in _Skins[SkinIndex].SkinList)
foreach (SkinElement element in _Skins[SkinIndex].SkinList.Values)
{
writer.WriteElementString(element.Name, element.Value);
}
@@ -489,14 +509,14 @@ namespace Vocaluxe.Base
skin.Path = path;
skin.FileName = file;
skin.SkinList = new List<SkinElement>();
skin.SkinList = new Dictionary<string, SkinElement>();
List<string> names = CHelper.GetValuesFromXML("Skins", navigator);
foreach (string str in names)
{
SkinElement sk = new SkinElement();
sk.Name = str;
sk.Value = String.Empty;
skin.SkinList.Add(sk);
skin.SkinList[str] = sk;
}
skin.VideoList = new List<SkinElement>();
@@ -573,16 +593,9 @@ namespace Vocaluxe.Base
public static STexture GetSkinTexture(string TextureName)
{
int SkinIndex = GetSkinIndex();
if (SkinIndex != -1)
if (SkinIndex != -1 && TextureName != null && _Skins[SkinIndex].SkinList.ContainsKey(TextureName))
{
for (int i = 0; i < _Skins[SkinIndex].SkinList.Count; i++)
{
SkinElement sk = _Skins[SkinIndex].SkinList[i];
if (sk.Name == TextureName)
{
return sk.Texture;
}
}
return _Skins[SkinIndex].SkinList[TextureName].Texture;
}
return new STexture(-1);
}
@@ -599,7 +612,7 @@ namespace Vocaluxe.Base
private static string GetSkinFileName(string SkinName, int SkinIndex, bool ReturnPath)
{
foreach (SkinElement sk in _Skins[SkinIndex].SkinList)
foreach (SkinElement sk in _Skins[SkinIndex].SkinList.Values)
{
if (sk.Name == SkinName)
{
+20 -18
View File
@@ -69,8 +69,11 @@ namespace Vocaluxe.Base
public int Y;
public bool LB; //left button click
public bool RB; //right button click
public bool MB; //middle button click
public bool LBH; //left button hold (when moving)
public bool RBH; //right button hold (when moving)
public bool MBH; //middle button hold (when moving)
public bool ModALT;
public bool ModSHIFT;
@@ -79,15 +82,17 @@ namespace Vocaluxe.Base
public Modifier Mod;
public int Wheel;
public MouseEvent(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool rb, int wheel, bool lbh, bool rbh)
public MouseEvent(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{
X = x;
Y = y;
LB = lb;
RB = rb;
MB = mb;
LBH = lbh;
RBH = rbh;
MBH = mbh;
ModALT = alt;
ModSHIFT = shift;
@@ -311,7 +316,7 @@ namespace Vocaluxe.Base
class CMouse
{
private List<MouseEvent> _EventsPool;
private List<MouseEvent> _ActualPool;
private List<MouseEvent> _CurrentPool;
private int _x = 0;
private int _y = 0;
@@ -321,8 +326,6 @@ namespace Vocaluxe.Base
private bool _ModALT;
private bool _ModCTRL;
private bool _ModSHIFT;
private System.Diagnostics.Stopwatch _timer;
public int X
{
@@ -343,15 +346,14 @@ namespace Vocaluxe.Base
_ModSHIFT = false;
_EventsPool = new List<MouseEvent>();
_ActualPool = new List<MouseEvent>();
_timer = new System.Diagnostics.Stopwatch();
_CurrentPool = new List<MouseEvent>();
}
private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool rb, int wheel, bool lbh, bool rbh)
private void Add(bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{
x = (int)((float)x * (float)CSettings.iRenderW / (float)CDraw.GetScreenWidth());
y = (int)((float)y * (float)CSettings.iRenderH / (float)CDraw.GetScreenHeight());
MouseEvent pool = new MouseEvent(alt, shift, ctrl, x, y, lb, rb, -wheel/120, lbh, rbh);
MouseEvent pool = new MouseEvent(alt, shift, ctrl, x, y, lb, rb, -wheel/120, lbh, rbh, mb, mbh);
lock (_CopyLock)
{
@@ -359,14 +361,11 @@ namespace Vocaluxe.Base
}
_x = x;
_y = y;
_timer.Reset();
_timer.Start();
}
private void Del(int index)
{
_ActualPool.RemoveAt(index);
_CurrentPool.RemoveAt(index);
}
private void CheckModifiers()
@@ -381,19 +380,22 @@ namespace Vocaluxe.Base
public void MouseMove(MouseEventArgs e)
{
CheckModifiers();
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right);
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right,
false, e.Button == MouseButtons.Middle);
}
public void MouseWheel(MouseEventArgs e)
{
CheckModifiers();
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right);
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, false, false, e.Delta, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right,
false, e.Button == MouseButtons.Middle);
}
public void MouseDown(MouseEventArgs e)
{
CheckModifiers();
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta, false, false);
Add(_ModALT, _ModSHIFT, _ModCTRL, e.X, e.Y, e.Button == MouseButtons.Left, e.Button == MouseButtons.Right, e.Delta, false, false,
e.Button == MouseButtons.Middle, false);
}
public void MouseUp(MouseEventArgs e)
@@ -404,9 +406,9 @@ namespace Vocaluxe.Base
public bool PollEvent(ref MouseEvent MouseEvent)
{
if (_ActualPool.Count > 0)
if (_CurrentPool.Count > 0)
{
MouseEvent = _ActualPool[0];
MouseEvent = _CurrentPool[0];
Del(0);
return true;
}
@@ -419,7 +421,7 @@ namespace Vocaluxe.Base
{
foreach (MouseEvent e in _EventsPool)
{
_ActualPool.Add(e);
_CurrentPool.Add(e);
}
_EventsPool.Clear();
}
+41 -32
View File
@@ -35,8 +35,9 @@ namespace Vocaluxe.Lib.Draw
private Size _SizeBeforeMinimize;
private Dictionary<int, STexture> _Textures;
private List<Texture> _D3DTextures;
private Dictionary<int, Texture> _D3DTextures;
private List<STextureQueque> _Queque;
private Queue<int> _IDs;
private Object MutexTexture = new Object();
@@ -48,7 +49,7 @@ namespace Vocaluxe.Lib.Draw
private int y = 0;
private int x = 0;
private STexture blankTexture;
private STexture _BlankTexture;
private Queue<TexturedColoredVertex> _Vertices;
private Queue<Texture> _VerticesTextures;
@@ -63,8 +64,13 @@ namespace Vocaluxe.Lib.Draw
{
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
_Textures = new Dictionary<int, STexture>();
_D3DTextures = new List<Texture>();
_D3DTextures = new Dictionary<int, Texture>();
_Queque = new List<STextureQueque>();
_IDs = new Queue<int>();
//Fill Queue with 100000 IDs
for (int i = 0; i < 100000; i++)
_IDs.Enqueue(i);
_Vertices = new Queue<TexturedColoredVertex>();
_VerticesTextures = new Queue<Texture>();
@@ -482,7 +488,7 @@ namespace Vocaluxe.Lib.Draw
Graphics g = Graphics.FromImage(blankMap);
g.Clear(Color.White);
g.Dispose();
blankTexture = AddTexture(blankMap);
_BlankTexture = AddTexture(blankMap);
blankMap.Dispose();
return true;
@@ -505,6 +511,10 @@ namespace Vocaluxe.Lib.Draw
EnterFullScreen();
}
//Resize window if aspect ratio is incorrect
if ((float)w / (float)h != CSettings.GetRenderAspect())
RResize();
while (_Run)
{
Application.DoEvents();
@@ -582,11 +592,14 @@ namespace Vocaluxe.Lib.Draw
public bool Unload()
{
//Dispose all textures
for (int i = 0; i < _D3DTextures.Count; i++)
foreach (KeyValuePair<int, Texture> p in _D3DTextures)
{
if (_D3DTextures[i] != null)
_D3DTextures[i].Dispose();
if (p.Value != null)
{
p.Value.Dispose();
}
}
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
_VertexBuffer.Dispose();
_IndexBuffer.Dispose();
@@ -712,7 +725,7 @@ namespace Vocaluxe.Lib.Draw
Surface textureSurface = tex.GetSurfaceLevel(0);
Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0);
backbufferSurface.Dispose();
_D3DTextures.Add(tex);
_D3DTextures.Add(_IDs.Peek(), tex);
texture.color = new SColorF(1f, 1f, 1f, 1f);
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
@@ -720,7 +733,7 @@ namespace Vocaluxe.Lib.Draw
texture.height = h;
texture.w2 = NextPowerOfTwo(texture.width);
texture.h2 = NextPowerOfTwo(texture.height);
texture.index = _D3DTextures.Count - 1;
texture.index = _IDs.Dequeue();
lock (MutexTexture)
{
@@ -786,7 +799,7 @@ namespace Vocaluxe.Lib.Draw
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
{
SColorF color = new SColorF(a / 255, g / 255, b / 255, a / 255);
DrawTexture(blankTexture, new SRectF(x1, y1, x2, y2, 1), color);
DrawTexture(_BlankTexture, new SRectF(x1, y1, x2, y2, 1), color);
}
/// <summary>
@@ -821,7 +834,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="rect">The coordinates in a SRectF struct</param>
public void DrawColor(SColorF color, SRectF rect)
{
DrawTexture(blankTexture, rect, color);
DrawTexture(_BlankTexture, rect, color);
}
#endregion Basic Draw Methods
#region Textures
@@ -890,13 +903,13 @@ namespace Vocaluxe.Lib.Draw
int w = bmp.Width;
int h = bmp.Height;
if (h >= w && w > MaxSize)
if (w > MaxSize)
{
h = (int)Math.Round((float)MaxSize / bmp.Width * bmp.Height);
w = MaxSize;
}
if (w >= h && h > MaxSize)
if (h > MaxSize)
{
w = (int)Math.Round((float)MaxSize / bmp.Height * bmp.Width);
h = MaxSize;
@@ -950,8 +963,8 @@ namespace Vocaluxe.Lib.Draw
texture.TexturePath = String.Empty;
lock (MutexTexture)
{
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
_D3DTextures.Add(_IDs.Peek(), t);
texture.index = _IDs.Dequeue();
_Textures[texture.index] = texture;
}
return texture;
@@ -987,8 +1000,8 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture)
{
_D3DTextures.Add(null);
texture.index = _D3DTextures.Count - 1;
_D3DTextures.Add(_IDs.Peek(), null);
texture.index = _IDs.Dequeue();
queque.ID = texture.index;
_Queque.Add(queque);
_Textures[texture.index] = texture;
@@ -1023,8 +1036,8 @@ namespace Vocaluxe.Lib.Draw
lock (MutexTexture)
{
_D3DTextures.Add(t);
texture.index = _D3DTextures.Count - 1;
_D3DTextures.Add(_IDs.Peek(), t);
texture.index = _IDs.Dequeue();
_Textures[texture.index] = texture;
}
return texture;
@@ -1054,7 +1067,7 @@ namespace Vocaluxe.Lib.Draw
/// <returns>True if succeeded</returns>
public bool UpdateTexture(ref STexture Texture, ref byte[] Data)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
if ((Texture.index >= 0) && (_Textures.Count > 0) && _TextureExists(ref Texture))
{
DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.None);
for (int i = 0; i < Data.Length; )
@@ -1107,8 +1120,9 @@ namespace Vocaluxe.Lib.Draw
if ((Texture.index >= 0) && (_Textures.Count > 0))
{
_D3DTextures[Texture.index].Dispose();
_D3DTextures[Texture.index] = null;
_D3DTextures.Remove(Texture.index);
_Textures.Remove(Texture.index);
_IDs.Enqueue(Texture.index);
Texture.index = -1;
Texture.ID = -1;
}
@@ -1122,8 +1136,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="Texture">The texture to be drawn</param>
public void DrawTexture(STexture Texture)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
DrawTexture(Texture, Texture.rect, Texture.color);
DrawTexture(Texture, Texture.rect, Texture.color);
}
/// <summary>
@@ -1133,8 +1146,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
public void DrawTexture(STexture Texture, SRectF rect)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
DrawTexture(Texture, rect, Texture.color, false);
DrawTexture(Texture, rect, Texture.color, false);
}
/// <summary>
@@ -1145,8 +1157,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
public void DrawTexture(STexture Texture, SRectF rect, SColorF color)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
DrawTexture(Texture, rect, color, false);
DrawTexture(Texture, rect, color, false);
}
/// <summary>
@@ -1158,8 +1169,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="bounds">A SRectF struct containing which part of the texture should be drawn</param>
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
DrawTexture(Texture, rect, color, bounds, false);
DrawTexture(Texture, rect, color, bounds, false);
}
/// <summary>
@@ -1171,8 +1181,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="mirrored">True if the texture should be mirrored</param>
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
DrawTexture(Texture, rect, color, new SRectF(0, 0, CSettings.iRenderW, CSettings.iRenderH, rect.Z), mirrored);
DrawTexture(Texture, rect, color, new SRectF(0, 0, CSettings.iRenderW, CSettings.iRenderH, rect.Z), mirrored);
}
/// <summary>
@@ -1185,7 +1194,7 @@ namespace Vocaluxe.Lib.Draw
/// <param name="mirrored">True if the texture should be mirrored</param>
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored)
{
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
if (_TextureExists(ref Texture))
{
if (_D3DTextures[Texture.index] == null)
return;
+2 -2
View File
@@ -724,13 +724,13 @@ namespace Vocaluxe.Lib.Draw
int w = bmp.Width;
int h = bmp.Height;
if (h >= w && w > MaxSize)
if (w > MaxSize)
{
h = (int)Math.Round((float)MaxSize / bmp.Width * bmp.Height);
w = MaxSize;
}
if (w >= h && h > MaxSize)
if (h > MaxSize)
{
w = (int)Math.Round((float)MaxSize / bmp.Height * bmp.Width);
h = MaxSize;
+18 -6
View File
@@ -43,9 +43,7 @@ namespace Vocaluxe.Lib.Song
if (Index >= _Lines.Count)
return false;
CLines lines = new CLines();
lines = Lines;
_Lines[Index] = lines;
_Lines[Index] = Lines;
return true;
}
@@ -549,9 +547,16 @@ namespace Vocaluxe.Lib.Song
#region Methods
public void AddLine(CLine Line)
{
AddLine(Line, true);
}
public void AddLine(CLine Line, bool updateTimings)
{
_Lines.Add(Line);
UpdateTimings();
if (updateTimings)
{
UpdateTimings();
}
}
public bool InsertLine(CLine Line, int Index)
@@ -581,16 +586,23 @@ namespace Vocaluxe.Lib.Song
_Lines.Clear();
}
public bool AddNote(CNote Note, int LineIndex)
public bool AddNote(CNote Note, int LineIndex, bool updateTimings)
{
if (_Lines.Count > LineIndex)
{
_Lines[LineIndex].AddNote(Note);
UpdateTimings();
if (updateTimings)
{
UpdateTimings();
}
return true;
}
return false;
}
public bool AddNote(CNote Note, int LineIndex)
{
return AddNote(Note, LineIndex, true);
}
public bool InsertNote(CNote Note, int LineIndex, int NoteIndex)
{
+6 -2
View File
@@ -463,6 +463,10 @@ namespace Vocaluxe.Lib.Song
TempC = (char)c;
} while ((TempC.CompareTo('E') != 0) && !sr.EndOfStream && (c == 19 || c == 16 || c == 13));
}
foreach(CLines lines in this.Notes.Lines)
{
lines.UpdateTimings();
}
}
catch (Exception e)
{
@@ -482,11 +486,11 @@ namespace Vocaluxe.Lib.Song
{
CLine line = new CLine();
line.AddNote(note);
lines.AddLine(line);
lines.AddLine(line, false);
}
else
{
lines.AddNote(note, lines.LineCount - 1);
lines.AddNote(note, lines.LineCount - 1, false);
}
}
+117 -86
View File
@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
@@ -33,126 +34,156 @@ namespace Vocaluxe
Application.DoEvents();
// Init Log
CLog.Init();
try
{
// Init Log
CLog.Init();
CSettings.CreateFolders();
Application.DoEvents();
CSettings.CreateFolders();
Application.DoEvents();
// Init Language
CLog.StartBenchmark(0, "Init Language");
CLanguage.Init();
CLog.StopBenchmark(0, "Init Language");
// Init Language
CLog.StartBenchmark(0, "Init Language");
CLanguage.Init();
CLog.StopBenchmark(0, "Init Language");
Application.DoEvents();
Application.DoEvents();
// load config
CLog.StartBenchmark(0, "Init Config");
CConfig.LoadCommandLineParams(args);
CConfig.UseCommandLineParamsBefore();
CConfig.Init();
CConfig.UseCommandLineParamsAfter();
CLog.StopBenchmark(0, "Init Config");
// load config
CLog.StartBenchmark(0, "Init Config");
CConfig.LoadCommandLineParams(args);
CConfig.UseCommandLineParamsBefore();
CConfig.Init();
CConfig.UseCommandLineParamsAfter();
CLog.StopBenchmark(0, "Init Config");
Application.DoEvents();
_SplashScreen = new SplashScreen();
Application.DoEvents();
Application.DoEvents();
_SplashScreen = new SplashScreen();
Application.DoEvents();
// Init Draw
CLog.StartBenchmark(0, "Init Draw");
CDraw.InitDraw();
CLog.StopBenchmark(0, "Init Draw");
// Init Draw
CLog.StartBenchmark(0, "Init Draw");
CDraw.InitDraw();
CLog.StopBenchmark(0, "Init Draw");
Application.DoEvents();
Application.DoEvents();
// Init Database
CLog.StartBenchmark(0, "Init Database");
CDataBase.Init();
CLog.StopBenchmark(0, "Init Database");
// Init Database
CLog.StartBenchmark(0, "Init Database");
CDataBase.Init();
CLog.StopBenchmark(0, "Init Database");
Application.DoEvents();
Application.DoEvents();
// Init Playback
CLog.StartBenchmark(0, "Init Playback");
CSound.PlaybackInit();
CLog.StopBenchmark(0, "Init Playback");
// Init Playback
CLog.StartBenchmark(0, "Init Playback");
CSound.PlaybackInit();
CLog.StopBenchmark(0, "Init Playback");
Application.DoEvents();
Application.DoEvents();
// Init Record
CLog.StartBenchmark(0, "Init Record");
CSound.RecordInit();
CLog.StopBenchmark(0, "Init Record");
// Init Record
CLog.StartBenchmark(0, "Init Record");
CSound.RecordInit();
CLog.StopBenchmark(0, "Init Record");
Application.DoEvents();
Application.DoEvents();
// Init Background Music
CLog.StartBenchmark(0, "Init Background Music");
CBackgroundMusic.Init();
CLog.StopBenchmark(0, "Init Background Music");
// Init Background Music
CLog.StartBenchmark(0, "Init Background Music");
CBackgroundMusic.Init();
CLog.StopBenchmark(0, "Init Background Music");
Application.DoEvents();
Application.DoEvents();
// Init Profiles
CLog.StartBenchmark(0, "Init Profiles");
CProfiles.Init();
CLog.StopBenchmark(0, "Init Profiles");
// Init Profiles
CLog.StartBenchmark(0, "Init Profiles");
CProfiles.Init();
CLog.StopBenchmark(0, "Init Profiles");
Application.DoEvents();
Application.DoEvents();
// Init Font
CLog.StartBenchmark(0, "Init Font");
CFonts.Init();
CLog.StopBenchmark(0, "Init Font");
// Init Font
CLog.StartBenchmark(0, "Init Font");
CFonts.Init();
CLog.StopBenchmark(0, "Init Font");
Application.DoEvents();
Application.DoEvents();
// Init VideoDecoder
CLog.StartBenchmark(0, "Init Videodecoder");
CVideo.Init();
CLog.StopBenchmark(0, "Init Videodecoder");
// Init VideoDecoder
CLog.StartBenchmark(0, "Init Videodecoder");
CVideo.Init();
CLog.StopBenchmark(0, "Init Videodecoder");
Application.DoEvents();
Application.DoEvents();
// Load Cover
CLog.StartBenchmark(0, "Init Cover");
CCover.Init();
CLog.StopBenchmark(0, "Init Cover");
// Load Cover
CLog.StartBenchmark(0, "Init Cover");
CCover.Init();
CLog.StopBenchmark(0, "Init Cover");
Application.DoEvents();
Application.DoEvents();
// Theme System
CLog.StartBenchmark(0, "Init Theme");
CTheme.InitTheme();
CLog.StopBenchmark(0, "Init Theme");
// Theme System
CLog.StartBenchmark(0, "Init Theme");
CTheme.InitTheme();
CLog.StopBenchmark(0, "Init Theme");
Application.DoEvents();
Application.DoEvents();
// Init Screens
CLog.StartBenchmark(0, "Init Screens");
CGraphics.InitGraphics();
CLog.StopBenchmark(0, "Init Screens");
// Init Screens
CLog.StartBenchmark(0, "Init Screens");
CGraphics.InitGraphics();
CLog.StopBenchmark(0, "Init Screens");
Application.DoEvents();
// Init Game;
CLog.StartBenchmark(0, "Init Game");
CGame.Init();
CLog.StopBenchmark(0, "Init Game");
Application.DoEvents();
// Init Game;
CLog.StartBenchmark(0, "Init Game");
CGame.Init();
CLog.StopBenchmark(0, "Init Game");
}
catch (Exception e)
{
MessageBox.Show("Error on start up: " + e.Message + e.StackTrace);
CLog.LogError("Error on start up: " + e.Message + e.StackTrace);
CloseProgram();
Environment.Exit(Environment.ExitCode);
}
Application.DoEvents();
// Start Main Loop
_SplashScreen.Close();
CDraw.MainLoop();
try
{
CDraw.MainLoop();
}
catch (Exception e)
{
MessageBox.Show("Unhandled error: " + e.Message + e.StackTrace);
CLog.LogError("Unhandled error: " + e.Message + e.StackTrace);
}
CloseProgram();
}
static void CloseProgram()
{
// Unloading
CSound.RecordCloseAll();
CSound.CloseAllStreams();
CVideo.VdCloseAll();
CDraw.Unload();
CLog.CloseAll();
CDataBase.CloseConnections();
try
{
CSound.RecordCloseAll();
CSound.CloseAllStreams();
CVideo.VdCloseAll();
CDraw.Unload();
CLog.CloseAll();
CDataBase.CloseConnections();
}
catch (Exception)
{
}
}
static Assembly AssemblyResolver(Object sender, ResolveEventArgs args)
+9 -2
View File
@@ -155,12 +155,19 @@ namespace Vocaluxe.Screens
CGraphics.FadeTo(EScreens.ScreenMain);
}
SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent);
if (MouseEvent.MB && CSongs.Category != -1)
{
Console.WriteLine("MB pressed");
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
}
else
SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent);
if (MouseEvent.LB && CSongs.NumVisibleSongs > 0 && SongMenus[htSongMenus(SongMenu)].GetActualSelection() != -1)
{
StartSong(SongMenus[htSongMenus(SongMenu)].GetSelectedSong());
}
return true;
}