diff --git a/Output/x64/acinerella.dll b/Output/x64/acinerella.dll index 41790e99..4fa95785 100644 Binary files a/Output/x64/acinerella.dll and b/Output/x64/acinerella.dll differ diff --git a/Output/x64/avcodec-54.dll b/Output/x64/avcodec-54.dll index dd2af535..37ff648d 100644 Binary files a/Output/x64/avcodec-54.dll and b/Output/x64/avcodec-54.dll differ diff --git a/Output/x64/avformat-54.dll b/Output/x64/avformat-54.dll index a7d5c0c4..406d4c1f 100644 Binary files a/Output/x64/avformat-54.dll and b/Output/x64/avformat-54.dll differ diff --git a/Output/x64/avutil-51.dll b/Output/x64/avutil-51.dll index 861e290b..638b40c5 100644 Binary files a/Output/x64/avutil-51.dll and b/Output/x64/avutil-51.dll differ diff --git a/Output/x64/swscale-2.dll b/Output/x64/swscale-2.dll index a883eacf..2649979b 100644 Binary files a/Output/x64/swscale-2.dll and b/Output/x64/swscale-2.dll differ diff --git a/Output/x86/acinerella.dll b/Output/x86/acinerella.dll index 87dfc0f3..29a05b55 100644 Binary files a/Output/x86/acinerella.dll and b/Output/x86/acinerella.dll differ diff --git a/Output/x86/avcodec-54.dll b/Output/x86/avcodec-54.dll index 21d6a7b7..1d56751b 100644 Binary files a/Output/x86/avcodec-54.dll and b/Output/x86/avcodec-54.dll differ diff --git a/Output/x86/avformat-54.dll b/Output/x86/avformat-54.dll index 0099c2cb..76385c1e 100644 Binary files a/Output/x86/avformat-54.dll and b/Output/x86/avformat-54.dll differ diff --git a/Output/x86/avutil-51.dll b/Output/x86/avutil-51.dll index 0ab13c9f..6117ea73 100644 Binary files a/Output/x86/avutil-51.dll and b/Output/x86/avutil-51.dll differ diff --git a/Output/x86/swscale-2.dll b/Output/x86/swscale-2.dll index 0cca8210..50d699f1 100644 Binary files a/Output/x86/swscale-2.dll and b/Output/x86/swscale-2.dll differ diff --git a/Vocaluxe/Base/CCover.cs b/Vocaluxe/Base/CCover.cs index fe5f4e3a..22b699d9 100644 --- a/Vocaluxe/Base/CCover.cs +++ b/Vocaluxe/Base/CCover.cs @@ -238,13 +238,13 @@ namespace Vocaluxe.Base { _Cover.Clear(); List cover = CHelper.GetValuesFromXML("Cover", navigator); - for (int i = 1; i <= cover.Count; i++) + for (int i = 0; i < cover.Count; i++) { SCover sk = new SCover(); string name = String.Empty; string value = String.Empty; - CHelper.GetValueFromXML("//root/Cover/Cover" + i + "/Name", navigator, ref name, String.Empty); - CHelper.GetValueFromXML("//root/Cover/Cover" + i + "/Path", navigator, ref value, String.Empty); + CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Name", navigator, ref name, String.Empty); + CHelper.GetValueFromXML("//root/Cover/" + cover[i] + "/Path", navigator, ref value, String.Empty); sk.Name = name; sk.Value = Path.Combine(coverTheme.Folder,value); if (File.Exists(Path.Combine(CSettings.sFolderCover, Path.Combine(coverTheme.Folder, value)))) diff --git a/Vocaluxe/Base/CLog.cs b/Vocaluxe/Base/CLog.cs index d75e2f36..ab2e1695 100644 --- a/Vocaluxe/Base/CLog.cs +++ b/Vocaluxe/Base/CLog.cs @@ -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() diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index 3b57408a..7c3838e7 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -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; diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index a3fc1a6b..8473cf25 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -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(); } } } diff --git a/Vocaluxe/Base/CTheme.cs b/Vocaluxe/Base/CTheme.cs index 639ebdac..66ee9023 100644 --- a/Vocaluxe/Base/CTheme.cs +++ b/Vocaluxe/Base/CTheme.cs @@ -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 SkinList; + public Dictionary SkinList; public List 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 keys = new List(_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(); + skin.SkinList = new Dictionary(); List 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(); @@ -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) { diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs index 909dc798..bfd28130 100644 --- a/Vocaluxe/Base/CUtility.cs +++ b/Vocaluxe/Base/CUtility.cs @@ -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 _EventsPool; - private List _ActualPool; + private List _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(); - _ActualPool = new List(); - _timer = new System.Diagnostics.Stopwatch(); + _CurrentPool = new List(); } - 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(); } diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 9745fa92..3141d237 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -35,8 +35,9 @@ namespace Vocaluxe.Lib.Draw private Size _SizeBeforeMinimize; private Dictionary _Textures; - private List _D3DTextures; + private Dictionary _D3DTextures; private List _Queque; + private Queue _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 _Vertices; private Queue _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(); - _D3DTextures = new List(); + _D3DTextures = new Dictionary(); _Queque = new List(); + _IDs = new Queue(); + + //Fill Queue with 100000 IDs + for (int i = 0; i < 100000; i++) + _IDs.Enqueue(i); _Vertices = new Queue(); _VerticesTextures = new Queue(); @@ -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 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); } /// @@ -821,7 +834,7 @@ namespace Vocaluxe.Lib.Draw /// The coordinates in a SRectF struct 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 /// True if succeeded 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 /// The texture to be drawn 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); } /// @@ -1133,8 +1146,7 @@ namespace Vocaluxe.Lib.Draw /// A SRectF struct containing the destination coordinates 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); } /// @@ -1145,8 +1157,7 @@ namespace Vocaluxe.Lib.Draw /// A SColorF struct containing a color which the texture will be colored in 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); } /// @@ -1158,8 +1169,7 @@ namespace Vocaluxe.Lib.Draw /// A SRectF struct containing which part of the texture should be drawn 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); } /// @@ -1171,8 +1181,7 @@ namespace Vocaluxe.Lib.Draw /// True if the texture should be mirrored 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); } /// @@ -1185,7 +1194,7 @@ namespace Vocaluxe.Lib.Draw /// True if the texture should be mirrored 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; diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 7809edce..54ee1fcf 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -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; diff --git a/Vocaluxe/Lib/Song/CNotes.cs b/Vocaluxe/Lib/Song/CNotes.cs index c732054e..43bb7a29 100644 --- a/Vocaluxe/Lib/Song/CNotes.cs +++ b/Vocaluxe/Lib/Song/CNotes.cs @@ -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) { diff --git a/Vocaluxe/Lib/Song/CSong.cs b/Vocaluxe/Lib/Song/CSong.cs index eed10907..dce672c1 100644 --- a/Vocaluxe/Lib/Song/CSong.cs +++ b/Vocaluxe/Lib/Song/CSong.cs @@ -468,6 +468,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) { @@ -487,11 +491,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); } } diff --git a/Vocaluxe/Program.cs b/Vocaluxe/Program.cs index 12c5f643..d5d50632 100644 --- a/Vocaluxe/Program.cs +++ b/Vocaluxe/Program.cs @@ -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 Profiles - CLog.StartBenchmark(0, "Init Profiles"); - CProfiles.Init(); - CLog.StopBenchmark(0, "Init Profiles"); + // Init Background Music + CLog.StartBenchmark(0, "Init Background Music"); + CBackgroundMusic.Init(); + CLog.StopBenchmark(0, "Init Background Music"); - Application.DoEvents(); + Application.DoEvents(); - // Init Font - CLog.StartBenchmark(0, "Init Font"); - CFonts.Init(); - CLog.StopBenchmark(0, "Init Font"); + // Init Profiles + CLog.StartBenchmark(0, "Init Profiles"); + CProfiles.Init(); + CLog.StopBenchmark(0, "Init Profiles"); - Application.DoEvents(); + Application.DoEvents(); - // Init VideoDecoder - CLog.StartBenchmark(0, "Init Videodecoder"); - CVideo.Init(); - CLog.StopBenchmark(0, "Init Videodecoder"); + // Init Font + CLog.StartBenchmark(0, "Init Font"); + CFonts.Init(); + CLog.StopBenchmark(0, "Init Font"); - Application.DoEvents(); + Application.DoEvents(); - // Load Cover - CLog.StartBenchmark(0, "Init Cover"); - CCover.Init(); - CLog.StopBenchmark(0, "Init Cover"); + // Init VideoDecoder + CLog.StartBenchmark(0, "Init Videodecoder"); + CVideo.Init(); + CLog.StopBenchmark(0, "Init Videodecoder"); - Application.DoEvents(); + Application.DoEvents(); - // Init Background Music - CLog.StartBenchmark(0, "Init Background Music"); - CBackgroundMusic.Init(); - CLog.StopBenchmark(0, "Init Background Music"); + // 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) diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 4ec9274e..df176860 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -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; }