Fixed DX Close Bug and some typos closes #15

This commit is contained in:
Flamefire committed 2013-04-28 12:24:48 +02:00
1 parent 81074d5a0a
commit 5f28c5a103
10 files changed
+69 -64

No files matched your search

@@ -501,7 +501,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
} }
#endregion PlayerNames #endregion PlayerNames
#region SongQueque #region SongQueue
if (CBase.Songs.GetNumVisibleSongs() < _NumSongs) if (CBase.Songs.GetNumVisibleSongs() < _NumSongs)
CBase.Songs.ResetPartySongSung(); CBase.Songs.ResetPartySongSung();
@@ -542,7 +542,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
s++; s++;
} }
return true; return true;
#endregion SongQueque #endregion SongQueue
} }
private void _SetNumJokers() private void _SetNumJokers()
+2 -2
View File
@@ -956,7 +956,7 @@ namespace Vocaluxe.Base
reader.Read(); reader.Read();
byte[] data = _GetBytes(reader); byte[] data = _GetBytes(reader);
reader.Dispose(); reader.Dispose();
tex = CDraw.QuequeTexture(w, h, ref data); tex = CDraw.EnqueueTexture(w, h, ref data);
return true; return true;
} }
} }
@@ -1006,7 +1006,7 @@ namespace Vocaluxe.Base
origin.Dispose(); origin.Dispose();
} }
tex = CDraw.QuequeTexture(w, h, ref data); tex = CDraw.EnqueueTexture(w, h, ref data);
command.CommandText = "INSERT INTO Cover (Path, width, height) VALUES (@path, @w, @h)"; command.CommandText = "INSERT INTO Cover (Path, width, height) VALUES (@path, @w, @h)";
command.Parameters.Add("@w", DbType.Int32).Value = w; command.Parameters.Add("@w", DbType.Int32).Value = w;
+2 -2
View File
@@ -211,9 +211,9 @@ namespace Vocaluxe.Base
return _Draw.AddTexture(w, h, ref data); return _Draw.AddTexture(w, h, ref data);
} }
public static STexture QuequeTexture(int w, int h, ref byte[] data) public static STexture EnqueueTexture(int w, int h, ref byte[] data)
{ {
return _Draw.QuequeTexture(w, h, ref data); return _Draw.EnqueueTexture(w, h, ref data);
} }
public static bool UpdateTexture(ref STexture texture, ref byte[] data) public static bool UpdateTexture(ref STexture texture, ref byte[] data)
+1 -1
View File
@@ -418,7 +418,7 @@ namespace Vocaluxe.Base
public static void LoadCover() public static void LoadCover()
{ {
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 return; //should be removed as soon as the other renderer are ready for queue
if (!SongsLoaded || CoverLoaded) if (!SongsLoaded || CoverLoaded)
return; return;
+18 -15
View File
@@ -29,12 +29,13 @@ using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Windows.Forms; using System.Windows.Forms;
using SlimDX.Windows;
using Vocaluxe.Base; using Vocaluxe.Base;
using VocaluxeLib.Menu; using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Draw namespace Vocaluxe.Lib.Draw
{ {
class CDirect3D : Form, IDraw class CDirect3D : RenderForm, IDraw
{ {
#region private vars #region private vars
private readonly CKeys _Keys; private readonly CKeys _Keys;
@@ -51,7 +52,7 @@ namespace Vocaluxe.Lib.Draw
private readonly Dictionary<int, STexture> _Textures; private readonly Dictionary<int, STexture> _Textures;
private readonly Dictionary<int, Texture> _D3DTextures; private readonly Dictionary<int, Texture> _D3DTextures;
private readonly List<STextureQueque> _Queque; private readonly List<STextureQueue> _Queue;
private readonly Queue<int> _IDs; private readonly Queue<int> _IDs;
private readonly Object _MutexTexture = new Object(); private readonly Object _MutexTexture = new Object();
@@ -81,7 +82,7 @@ namespace Vocaluxe.Lib.Draw
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon)); Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon));
_Textures = new Dictionary<int, STexture>(); _Textures = new Dictionary<int, STexture>();
_D3DTextures = new Dictionary<int, Texture>(); _D3DTextures = new Dictionary<int, Texture>();
_Queque = new List<STextureQueque>(); _Queue = new List<STextureQueue>();
_IDs = new Queue<int>(); _IDs = new Queue<int>();
//Fill Queue with 100000 IDs //Fill Queue with 100000 IDs
@@ -97,7 +98,7 @@ namespace Vocaluxe.Lib.Draw
{ {
_D3D = new Direct3D(); _D3D = new Direct3D();
} }
catch (Direct3D9NotFoundException e) catch (Direct3DX9NotFoundException e)
{ {
MessageBox.Show("No DirectX runtimes were found, please download and install them " + MessageBox.Show("No DirectX runtimes were found, please download and install them " +
"from http://www.microsoft.com/download/en/details.aspx?id=8109", "from http://www.microsoft.com/download/en/details.aspx?id=8109",
@@ -515,13 +516,15 @@ namespace Vocaluxe.Lib.Draw
//We want to begin drawing //We want to begin drawing
if (_Device.BeginScene().IsFailure) if (_Device.BeginScene().IsFailure)
CLog.LogError("Failed to begin scene"); CLog.LogError("Failed to begin scene");
_CheckQueque(); _CheckQueue();
_Run = _Run && CGraphics.Draw(); if (!CGraphics.Draw())
_Run = false;
_RenderVertexBuffer(); _RenderVertexBuffer();
//We finished drawing the frame //We finished drawing the frame
if (_Device.EndScene().IsFailure) if (_Device.EndScene().IsFailure)
CLog.LogError("Failed to end scene"); CLog.LogError("Failed to end scene");
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse); if (!CGraphics.UpdateGameLogic(_Keys, _Mouse))
_Run = false;
try try
{ {
//Now push the frame to the Viewport //Now push the frame to the Viewport
@@ -1010,10 +1013,10 @@ namespace Vocaluxe.Lib.Draw
return t; return t;
} }
public STexture QuequeTexture(int w, int h, ref byte[] data) public STexture EnqueueTexture(int w, int h, ref byte[] data)
{ {
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
STextureQueque queque = new STextureQueque {Data = data, Height = h, Width = w}; STextureQueue queue = new STextureQueue {Data = data, Height = h, Width = w};
texture.Height = h; texture.Height = h;
texture.Width = w; texture.Width = w;
@@ -1022,8 +1025,8 @@ namespace Vocaluxe.Lib.Draw
{ {
_D3DTextures.Add(_IDs.Peek(), null); _D3DTextures.Add(_IDs.Peek(), null);
texture.Index = _IDs.Dequeue(); texture.Index = _IDs.Dequeue();
queque.ID = texture.Index; queue.ID = texture.Index;
_Queque.Add(queque); _Queue.Add(queue);
_Textures[texture.Index] = texture; _Textures[texture.Index] = texture;
} }
return texture; return texture;
@@ -1405,14 +1408,14 @@ namespace Vocaluxe.Lib.Draw
} }
#endregion drawing #endregion drawing
private void _CheckQueque() private void _CheckQueue()
{ {
lock (_MutexTexture) lock (_MutexTexture)
{ {
if (_Queque.Count == 0) if (_Queue.Count == 0)
return; return;
STextureQueque q = _Queque[0]; STextureQueue q = _Queue[0];
STexture texture; STexture texture;
if (_Textures.ContainsKey(q.ID)) if (_Textures.ContainsKey(q.ID))
texture = _Textures[q.ID]; texture = _Textures[q.ID];
@@ -1423,7 +1426,7 @@ namespace Vocaluxe.Lib.Draw
_D3DTextures[q.ID] = t; _D3DTextures[q.ID] = t;
_Textures[texture.Index] = texture; _Textures[texture.Index] = texture;
_Queque.RemoveAt(0); _Queue.RemoveAt(0);
} }
} }
+1 -1
View File
@@ -418,7 +418,7 @@ namespace Vocaluxe.Lib.Draw
return new STexture(-1); return new STexture(-1);
} }
public STexture QuequeTexture(int w, int h, ref byte[] data) public STexture EnqueueTexture(int w, int h, ref byte[] data)
{ {
return AddTexture(w, h, ref data); return AddTexture(w, h, ref data);
} }
+16 -14
View File
@@ -41,7 +41,7 @@ namespace Vocaluxe.Lib.Draw
public int Height; public int Height;
}; };
struct STextureQueque struct STextureQueue
{ {
public int ID; public int ID;
public int Width; public int Width;
@@ -63,7 +63,7 @@ namespace Vocaluxe.Lib.Draw
private readonly Dictionary<int, STexture> _Textures; private readonly Dictionary<int, STexture> _Textures;
private readonly Queue<int> _IDs; private readonly Queue<int> _IDs;
private readonly List<STextureQueque> _Queque; private readonly List<STextureQueue> _Queue;
private readonly Object _MutexTexture = new Object(); private readonly Object _MutexTexture = new Object();
@@ -80,7 +80,7 @@ namespace Vocaluxe.Lib.Draw
Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon)); Icon = new Icon(Path.Combine(Environment.CurrentDirectory, CSettings.Icon));
_Textures = new Dictionary<int, STexture>(); _Textures = new Dictionary<int, STexture>();
_Queque = new List<STextureQueque>(); _Queue = new List<STextureQueue>();
_IDs = new Queue<int>(1000000); _IDs = new Queue<int>(1000000);
for (int i = 1; i < 1000000; i++) for (int i = 1; i < 1000000; i++)
@@ -412,15 +412,17 @@ namespace Vocaluxe.Lib.Draw
if (_Run) if (_Run)
{ {
ClearScreen(); ClearScreen();
_Run = _Run && CGraphics.Draw(); if (!CGraphics.Draw())
_Run = false;
if (!CGraphics.UpdateGameLogic(_Keys, _Mouse))
_Run = false;
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
_Control.SwapBuffers(); _Control.SwapBuffers();
if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen)) if ((CSettings.IsFullScreen && !_Fullscreen) || (!CSettings.IsFullScreen && _Fullscreen))
_ToggleFullScreen(); _ToggleFullScreen();
_CheckQueque(); _CheckQueue();
if (CTime.IsRunning()) if (CTime.IsRunning())
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds()); delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
@@ -907,10 +909,10 @@ namespace Vocaluxe.Lib.Draw
return texture; return texture;
} }
public STexture QuequeTexture(int w, int h, ref byte[] data) public STexture EnqueueTexture(int w, int h, ref byte[] data)
{ {
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
STextureQueque queque = new STextureQueque {Data = data, Height = h, Width = w}; STextureQueue queue = new STextureQueue {Data = data, Height = h, Width = w};
texture.Height = h; texture.Height = h;
texture.Width = w; texture.Width = w;
@@ -918,8 +920,8 @@ namespace Vocaluxe.Lib.Draw
lock (_MutexTexture) lock (_MutexTexture)
{ {
texture.Index = _IDs.Dequeue(); texture.Index = _IDs.Dequeue();
queque.ID = texture.Index; queue.ID = texture.Index;
_Queque.Add(queque); _Queue.Add(queue);
_Textures[texture.Index] = texture; _Textures[texture.Index] = texture;
} }
@@ -1333,14 +1335,14 @@ namespace Vocaluxe.Lib.Draw
return _Textures.Count; return _Textures.Count;
} }
private void _CheckQueque() private void _CheckQueue()
{ {
lock (_MutexTexture) lock (_MutexTexture)
{ {
if (_Queque.Count == 0) if (_Queue.Count == 0)
return; return;
STextureQueque q = _Queque[0]; STextureQueue q = _Queue[0];
STexture texture = new STexture(-1); STexture texture = new STexture(-1);
if (_Textures.ContainsKey(q.ID)) if (_Textures.ContainsKey(q.ID))
texture = _Textures[q.ID]; texture = _Textures[q.ID];
@@ -1407,7 +1409,7 @@ namespace Vocaluxe.Lib.Draw
_Textures[texture.Index] = texture; _Textures[texture.Index] = texture;
q.Data = null; q.Data = null;
_Queque.RemoveAt(0); _Queue.RemoveAt(0);
} }
} }
#endregion Textures #endregion Textures
+1 -1
View File
@@ -52,7 +52,7 @@ namespace Vocaluxe.Lib.Draw
STexture AddTexture(Bitmap bitmap); STexture AddTexture(Bitmap bitmap);
STexture AddTexture(int w, int h, IntPtr data); STexture AddTexture(int w, int h, IntPtr data);
STexture AddTexture(int w, int h, ref byte[] data); STexture AddTexture(int w, int h, ref byte[] data);
STexture QuequeTexture(int w, int h, ref byte[] data); STexture EnqueueTexture(int w, int h, ref byte[] data);
bool UpdateTexture(ref STexture texture, ref byte[] data); bool UpdateTexture(ref STexture texture, ref byte[] data);
bool UpdateTexture(ref STexture texture, IntPtr data); bool UpdateTexture(ref STexture texture, IntPtr data);
+3 -3
View File
@@ -948,9 +948,9 @@ namespace Vocaluxe.Screens
private void _UpdateMedleyCountdown() private void _UpdateMedleyCountdown()
{ {
if (CGame.GetSong() != null) CSong song = CGame.GetSong();
{ if (song != null)
CSong song = CGame.GetSong(); {
float currentTime = _CurrentTime - song.Start; float currentTime = _CurrentTime - song.Start;
float timeToFirstMedleyNote = (CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap - song.Start); float timeToFirstMedleyNote = (CGame.GetTimeFromBeats(song.Medley.StartBeat, song.BPM) + song.Gap - song.Start);
if (currentTime < timeToFirstMedleyNote && CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY) if (currentTime < timeToFirstMedleyNote && CGame.GameMode == EGameMode.TR_GAMEMODE_MEDLEY)
+23 -23
View File
@@ -39,22 +39,22 @@ namespace Vocaluxe.SongQueue
class CSongQueue : ISongQueue class CSongQueue : ISongQueue
{ {
private List<SSongQueueEntry> _SongQueque; private List<SSongQueueEntry> _SongQueue;
private int _CurrentSong; private int _CurrentSong;
private CPoints _Points; private CPoints _Points;
#region Implementation #region Implementation
public void Init() public void Init()
{ {
_SongQueque = new List<SSongQueueEntry>(); _SongQueue = new List<SSongQueueEntry>();
Reset(); Reset();
CGameModes.Init(); CGameModes.Init();
} }
public EGameMode GetCurrentGameMode() public EGameMode GetCurrentGameMode()
{ {
if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count)
return _SongQueque[_CurrentSong].GameMode; return _SongQueue[_CurrentSong].GameMode;
return EGameMode.TR_GAMEMODE_NORMAL; return EGameMode.TR_GAMEMODE_NORMAL;
} }
@@ -73,7 +73,7 @@ namespace Vocaluxe.SongQueue
if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet) if (gameMode == EGameMode.TR_GAMEMODE_DUET && !CSongs.GetSong(songID).IsDuet)
return false; return false;
_SongQueque.Add(new SSongQueueEntry(songID, gameMode)); _SongQueue.Add(new SSongQueueEntry(songID, gameMode));
return true; return true;
} }
@@ -89,11 +89,11 @@ namespace Vocaluxe.SongQueue
private bool _RemoveSong(int songID) private bool _RemoveSong(int songID)
{ {
for (int i = 0; i < _SongQueque.Count; i++) for (int i = 0; i < _SongQueue.Count; i++)
{ {
if (_SongQueque[i].SongID != songID) if (_SongQueue[i].SongID != songID)
continue; continue;
_SongQueque.RemoveAt(i); _SongQueue.RemoveAt(i);
return true; return true;
} }
return false; return false;
@@ -101,7 +101,7 @@ namespace Vocaluxe.SongQueue
public void ClearSongs() public void ClearSongs()
{ {
_SongQueque.Clear(); _SongQueue.Clear();
} }
public void Reset() public void Reset()
@@ -111,22 +111,22 @@ namespace Vocaluxe.SongQueue
public void Start(SPlayer[] players) public void Start(SPlayer[] players)
{ {
_Points = new CPoints(_SongQueque.Count, players); _Points = new CPoints(_SongQueue.Count, players);
} }
public void NextRound(SPlayer[] players) public void NextRound(SPlayer[] players)
{ {
if (_CurrentSong < _SongQueque.Count && _SongQueque.Count > 0) if (_CurrentSong < _SongQueue.Count && _SongQueue.Count > 0)
{ {
if (_CurrentSong > -1) if (_CurrentSong > -1)
{ {
_Points.SetPoints( _Points.SetPoints(
_CurrentSong, _CurrentSong,
_SongQueque[_CurrentSong].SongID, _SongQueue[_CurrentSong].SongID,
players, players,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY, _SongQueue[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_MEDLEY,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET, _SongQueue[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_DUET,
_SongQueque[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG); _SongQueue[_CurrentSong].GameMode == EGameMode.TR_GAMEMODE_SHORTSONG);
} }
_CurrentSong++; _CurrentSong++;
} }
@@ -134,7 +134,7 @@ namespace Vocaluxe.SongQueue
public bool IsFinished() public bool IsFinished()
{ {
return _CurrentSong == _SongQueque.Count || _SongQueque.Count == 0; return _CurrentSong == _SongQueue.Count || _SongQueue.Count == 0;
} }
public int GetCurrentRoundNr() public int GetCurrentRoundNr()
@@ -144,28 +144,28 @@ namespace Vocaluxe.SongQueue
public CSong GetSong() public CSong GetSong()
{ {
if (_CurrentSong >= 0 && _CurrentSong < _SongQueque.Count) if (_CurrentSong >= 0 && _CurrentSong < _SongQueue.Count)
CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueque[_CurrentSong].SongID); CGameModes.Get(GetCurrentGameMode()).GetSong(_SongQueue[_CurrentSong].SongID);
return null; return null;
} }
public int GetNumSongs() public int GetNumSongs()
{ {
return _SongQueque.Count; return _SongQueue.Count;
} }
public CSong GetSong(int num) public CSong GetSong(int num)
{ {
if (num - 1 < _SongQueque.Count && num > 0) if (num - 1 < _SongQueue.Count && num > 0)
return CSongs.GetSong(_SongQueque[num - 1].SongID); return CSongs.GetSong(_SongQueue[num - 1].SongID);
return null; return null;
} }
public EGameMode GetGameMode(int num) public EGameMode GetGameMode(int num)
{ {
if (num - 1 < _SongQueque.Count && num > 0) if (num - 1 < _SongQueue.Count && num > 0)
return _SongQueque[num - 1].GameMode; return _SongQueue[num - 1].GameMode;
return EGameMode.TR_GAMEMODE_NORMAL; return EGameMode.TR_GAMEMODE_NORMAL;
} }