Merge remote-tracking branch 'xDarcice/release-0.1' into release-0.1
This commit is contained in:
commit
a1df3029fa
3 files changed
+511
-67
No files matched your search
@@ -827,7 +827,7 @@ namespace Vocaluxe.Base
|
|||||||
Category = -1;
|
Category = -1;
|
||||||
_SongsLoaded = true;
|
_SongsLoaded = true;
|
||||||
|
|
||||||
if (CConfig.Renderer == ERenderer.TR_CONFIG_OPENGL)
|
if (CConfig.Renderer != ERenderer.TR_CONFIG_SOFTWARE)
|
||||||
{
|
{
|
||||||
CLog.StartBenchmark(2, "Load Cover");
|
CLog.StartBenchmark(2, "Load Cover");
|
||||||
for (int i = 0; i < _Songs.Count; i++)
|
for (int i = 0; i < _Songs.Count; i++)
|
||||||
@@ -849,7 +849,7 @@ namespace Vocaluxe.Base
|
|||||||
|
|
||||||
public static void LoadCover(long WaitTime, int NumLoads)
|
public static void LoadCover(long WaitTime, int NumLoads)
|
||||||
{
|
{
|
||||||
if (CConfig.Renderer == ERenderer.TR_CONFIG_OPENGL)
|
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 queque
|
||||||
|
|
||||||
if (!SongsLoaded)
|
if (!SongsLoaded)
|
||||||
|
|||||||
+461
-40
@@ -36,6 +36,9 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
private List<STexture> _Textures;
|
private List<STexture> _Textures;
|
||||||
private List<Texture> _D3DTextures;
|
private List<Texture> _D3DTextures;
|
||||||
|
private List<STextureQueque> _Queque;
|
||||||
|
|
||||||
|
private Object MutexTexture = new Object();
|
||||||
|
|
||||||
private VertexBuffer _VertexBuffer;
|
private VertexBuffer _VertexBuffer;
|
||||||
|
|
||||||
@@ -46,14 +49,20 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
private Bitmap blankMap;
|
private Bitmap blankMap;
|
||||||
private STexture blankTexture;
|
private STexture blankTexture;
|
||||||
|
private Texture transparentTexture;
|
||||||
|
|
||||||
#endregion private vars
|
#endregion private vars
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new Instance of the CDirect3D Class
|
||||||
|
/// </summary>
|
||||||
public CDirect3D()
|
public CDirect3D()
|
||||||
{
|
{
|
||||||
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
|
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
|
||||||
_Textures = new List<STexture>();
|
_Textures = new List<STexture>();
|
||||||
_D3DTextures = new List<Texture>();
|
_D3DTextures = new List<Texture>();
|
||||||
|
_Queque = new List<STextureQueque>();
|
||||||
|
|
||||||
_Keys = new CKeys();
|
_Keys = new CKeys();
|
||||||
_D3D = new Direct3D();
|
_D3D = new Direct3D();
|
||||||
|
|
||||||
@@ -86,6 +95,8 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
_PresentParameters.Multisample = MultisampleType.None;
|
_PresentParameters.Multisample = MultisampleType.None;
|
||||||
_PresentParameters.MultisampleQuality = 0;
|
_PresentParameters.MultisampleQuality = 0;
|
||||||
|
|
||||||
|
//Apply antialiasing and check if antialiasing mode is supported
|
||||||
|
#region Antialiasing
|
||||||
int quality = 0;
|
int quality = 0;
|
||||||
if (CConfig.AAMode == EAntiAliasingModes.x0)
|
if (CConfig.AAMode == EAntiAliasingModes.x0)
|
||||||
{
|
{
|
||||||
@@ -132,12 +143,15 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
else
|
else
|
||||||
CLog.LogError("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA");
|
CLog.LogError("[Direct3D] This AAMode is not supported by this device or driver, fallback to no AA");
|
||||||
}
|
}
|
||||||
|
#endregion Antialiasing
|
||||||
|
|
||||||
if(CConfig.VSync == EOffOn.TR_CONFIG_ON)
|
//Apply the VSync configuration
|
||||||
|
if (CConfig.VSync == EOffOn.TR_CONFIG_ON)
|
||||||
_PresentParameters.PresentationInterval = PresentInterval.Default;
|
_PresentParameters.PresentationInterval = PresentInterval.Default;
|
||||||
else
|
else
|
||||||
_PresentParameters.PresentationInterval = PresentInterval.Immediate;
|
_PresentParameters.PresentationInterval = PresentInterval.Immediate;
|
||||||
|
|
||||||
|
//GMA 950 graphics devices can only process vertices in software mode
|
||||||
Capabilities caps = _D3D.GetDeviceCaps(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware);
|
Capabilities caps = _D3D.GetDeviceCaps(_D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware);
|
||||||
CreateFlags flags = CreateFlags.None;
|
CreateFlags flags = CreateFlags.None;
|
||||||
if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0)
|
if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) != 0)
|
||||||
@@ -148,13 +162,15 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
this.CenterToScreen();
|
this.CenterToScreen();
|
||||||
|
|
||||||
blankMap = new Bitmap(1, 1); //Quick and Dirty, used for DrawColor
|
//This creates a new white texture and adds it to the texture pool
|
||||||
|
//This texture is used for the DrawRect method
|
||||||
|
blankMap = new Bitmap(1, 1);
|
||||||
Graphics g = Graphics.FromImage(blankMap);
|
Graphics g = Graphics.FromImage(blankMap);
|
||||||
g.Clear(Color.White);
|
g.Clear(Color.White);
|
||||||
g.Dispose();
|
g.Dispose();
|
||||||
blankTexture = AddTexture(blankMap);
|
blankTexture = AddTexture(blankMap);
|
||||||
h = ClientSize.Height;
|
|
||||||
w = ClientSize.Width;
|
transparentTexture = new Texture(_Device, 1, 1, 0, Usage.None, Format.A8R8G8B8, Pool.Managed);
|
||||||
blankMap.Dispose();
|
blankMap.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -186,9 +202,12 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
RResize();
|
RResize();
|
||||||
}
|
}
|
||||||
#endregion form events
|
#endregion form events
|
||||||
|
/// <summary>
|
||||||
|
/// Resizes the viewport
|
||||||
|
/// </summary>
|
||||||
private void RResize()
|
private void RResize()
|
||||||
{
|
{
|
||||||
|
// The window was minimized, so restore it to the last known size
|
||||||
if (ClientSize.Width == 0 || ClientSize.Height == 0)
|
if (ClientSize.Width == 0 || ClientSize.Height == 0)
|
||||||
{
|
{
|
||||||
ClientSize = _SizeBeforeMinimize;
|
ClientSize = _SizeBeforeMinimize;
|
||||||
@@ -202,28 +221,41 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
if ((float)w / (float)h > CSettings.GetRenderAspect())
|
if ((float)w / (float)h > CSettings.GetRenderAspect())
|
||||||
{
|
{
|
||||||
|
//The windows's width is too big
|
||||||
w = (int)Math.Round((float)h * CSettings.GetRenderAspect());
|
w = (int)Math.Round((float)h * CSettings.GetRenderAspect());
|
||||||
x = (ClientSize.Width - w) / 2;
|
x = (ClientSize.Width - w) / 2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
//The windows's height is too big
|
||||||
h = (int)Math.Round((float)w / CSettings.GetRenderAspect());
|
h = (int)Math.Round((float)w / CSettings.GetRenderAspect());
|
||||||
y = (ClientSize.Height - h) / 2;
|
y = (ClientSize.Height - h) / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Apply the new sizes to the PresentParameters
|
||||||
_PresentParameters.BackBufferWidth = ClientSize.Width;
|
_PresentParameters.BackBufferWidth = ClientSize.Width;
|
||||||
_PresentParameters.BackBufferHeight = ClientSize.Height;
|
_PresentParameters.BackBufferHeight = ClientSize.Height;
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
|
//To set new PresentParameters the device has to be resetted
|
||||||
Reset();
|
Reset();
|
||||||
|
//All configurations got flushed due to Reset(), so apply them again
|
||||||
Init();
|
Init();
|
||||||
|
|
||||||
|
//Set the new Viewport
|
||||||
_Device.Viewport = new Viewport(x, y, w, h);
|
_Device.Viewport = new Viewport(x, y, w, h);
|
||||||
|
//Store size so it can get restored after the window gets minimized
|
||||||
_SizeBeforeMinimize = ClientSize;
|
_SizeBeforeMinimize = ClientSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Triggers the Fullscreen mode
|
||||||
|
/// </summary>
|
||||||
private void EnterFullScreen()
|
private void EnterFullScreen()
|
||||||
{
|
{
|
||||||
|
//This currently not using real fullscreen mode but a borderless window
|
||||||
|
//Real fullscreen could be gained setting _PresentParameters.Windowed = true
|
||||||
|
//And calling Reset() and Init() after
|
||||||
_OldSize = this.ClientSize;
|
_OldSize = this.ClientSize;
|
||||||
this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
|
this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
|
||||||
this.FormBorderStyle = FormBorderStyle.None;
|
this.FormBorderStyle = FormBorderStyle.None;
|
||||||
@@ -237,7 +269,9 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
CConfig.SaveConfig();
|
CConfig.SaveConfig();
|
||||||
}
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Triggers the windowed mode
|
||||||
|
/// </summary>
|
||||||
private void LeaveFullScreen()
|
private void LeaveFullScreen()
|
||||||
{
|
{
|
||||||
this.ClientSize = _OldSize;
|
this.ClientSize = _OldSize;
|
||||||
@@ -312,7 +346,13 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
#region implementation
|
#region implementation
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inits the Device
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if it succeeded else false</returns>
|
||||||
public bool Init()
|
public bool Init()
|
||||||
|
{
|
||||||
|
if (!_Device.Disposed)
|
||||||
{
|
{
|
||||||
this.Text = CSettings.GetFullVersionText();
|
this.Text = CSettings.GetFullVersionText();
|
||||||
Matrix translate = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
Matrix translate = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
||||||
@@ -327,7 +367,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
_Device.SetRenderState(RenderState.Lighting, false);
|
_Device.SetRenderState(RenderState.Lighting, false);
|
||||||
_Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
|
_Device.SetRenderState(RenderState.DestinationBlend, Blend.InverseSourceAlpha);
|
||||||
_Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
_Device.SetRenderState(RenderState.SourceBlend, Blend.SourceAlpha);
|
||||||
if(_PresentParameters.Multisample != MultisampleType.None)
|
if (_PresentParameters.Multisample != MultisampleType.None)
|
||||||
_Device.SetRenderState(RenderState.MultisampleAntialias, true);
|
_Device.SetRenderState(RenderState.MultisampleAntialias, true);
|
||||||
_Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
|
_Device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear);
|
||||||
_Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
|
_Device.SetSamplerState(0, SamplerState.MagFilter, TextureFilter.Linear);
|
||||||
@@ -339,7 +379,12 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
|
_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Starts the rendering
|
||||||
|
/// </summary>
|
||||||
public void MainLoop()
|
public void MainLoop()
|
||||||
{
|
{
|
||||||
_Run = true;
|
_Run = true;
|
||||||
@@ -358,23 +403,33 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
if (_Run)
|
if (_Run)
|
||||||
{
|
{
|
||||||
|
//Clear the previous Frame
|
||||||
ClearScreen();
|
ClearScreen();
|
||||||
|
//We want to begin drawing
|
||||||
_Device.BeginScene();
|
_Device.BeginScene();
|
||||||
|
CheckQueque();
|
||||||
_Run = _Run && CGraphics.Draw();
|
_Run = _Run && CGraphics.Draw();
|
||||||
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
|
//We finished drawing the frame
|
||||||
_Device.EndScene();
|
_Device.EndScene();
|
||||||
|
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
//Now push the frame to the Viewport
|
||||||
_Device.Present();
|
_Device.Present();
|
||||||
}
|
}
|
||||||
catch (Direct3D9Exception)
|
catch (Direct3D9Exception)
|
||||||
{
|
{
|
||||||
if (_Device.TestCooperativeLevel() == ResultCode.DeviceNotReset) //Do only reset when the device in a resetable state!
|
//In Direct3D devices can get lost.
|
||||||
|
//This happens for example when opening the Task Manager in Vista/Windows 7 or if a UAC message is opening
|
||||||
|
//We need to reset the device to get it to workable state again
|
||||||
|
//After a reset Init() needs to be called because all data in the Direct3D default pool are lost and need to be recreated
|
||||||
|
if (_Device.TestCooperativeLevel() == ResultCode.DeviceNotReset)
|
||||||
{
|
{
|
||||||
Reset();
|
Reset();
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Apply fullscreen mode
|
||||||
if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen))
|
if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen))
|
||||||
{
|
{
|
||||||
if (!_fullscreen)
|
if (!_fullscreen)
|
||||||
@@ -387,7 +442,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
if (delay >= 1)
|
if (delay >= 1)
|
||||||
System.Threading.Thread.Sleep(delay);
|
System.Threading.Thread.Sleep(delay);
|
||||||
|
//Calculate the FPS Rate and restart the timer after a frame
|
||||||
CTime.CalculateFPS();
|
CTime.CalculateFPS();
|
||||||
CTime.Restart();
|
CTime.Restart();
|
||||||
}
|
}
|
||||||
@@ -396,19 +451,28 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the device, all objects in the Direct3D default pool get flushed and need to be recreated
|
||||||
|
/// </summary>
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
|
//Dispose all objects in the default pool, those need to be recreated
|
||||||
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
|
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
|
||||||
_VertexBuffer.Dispose();
|
_VertexBuffer.Dispose();
|
||||||
_Device.Reset(_PresentParameters);
|
_Device.Reset(_PresentParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Unloads all Textures and other objects used by Direct3D for rendering
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public bool Unload()
|
public bool Unload()
|
||||||
{
|
{
|
||||||
|
//Dispose all textures
|
||||||
for (int i = 0; i < _D3DTextures.Count; i++)
|
for (int i = 0; i < _D3DTextures.Count; i++)
|
||||||
{
|
{
|
||||||
|
if(_D3DTextures[i] != null)
|
||||||
_D3DTextures[i].Dispose();
|
_D3DTextures[i].Dispose();
|
||||||
|
|
||||||
}
|
}
|
||||||
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
|
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
|
||||||
_VertexBuffer.Dispose();
|
_VertexBuffer.Dispose();
|
||||||
@@ -417,21 +481,40 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current viewport width
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current viewport width</returns>
|
||||||
public int GetScreenWidth()
|
public int GetScreenWidth()
|
||||||
{
|
{
|
||||||
return _Device.Viewport.Width;
|
return _Device.Viewport.Width;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the current viewport height
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The current viewport height</returns>
|
||||||
public int GetScreenHeight()
|
public int GetScreenHeight()
|
||||||
{
|
{
|
||||||
return _Device.Viewport.Height;
|
return _Device.Viewport.Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the bounds for a CText object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">The CText object of which the bounds should be calculated for</param>
|
||||||
|
/// <returns>RectangleF object containing the bounds</returns>
|
||||||
public RectangleF GetTextBounds(CText text)
|
public RectangleF GetTextBounds(CText text)
|
||||||
{
|
{
|
||||||
return GetTextBounds(text, text.Height);
|
return GetTextBounds(text, text.Height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the bounds for a CText object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">The CText object of which the bounds should be calculated for</param>
|
||||||
|
/// <param name="Height">The height of the CText object</param>
|
||||||
|
/// <returns>RectangleF object containing the bounds</returns>
|
||||||
public RectangleF GetTextBounds(CText text, float Height)
|
public RectangleF GetTextBounds(CText text, float Height)
|
||||||
{
|
{
|
||||||
CFonts.Height = Height;
|
CFonts.Height = Height;
|
||||||
@@ -442,21 +525,38 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
#region Basic Draw Methods
|
#region Basic Draw Methods
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes all textures from the screen
|
||||||
|
/// </summary>
|
||||||
public void ClearScreen()
|
public void ClearScreen()
|
||||||
{
|
{
|
||||||
_Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
|
_Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Not implemented yet
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public STexture CopyScreen()
|
public STexture CopyScreen()
|
||||||
{
|
{
|
||||||
|
//FIXME
|
||||||
STexture texture = new STexture(-1);
|
STexture texture = new STexture(-1);
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Not implemented yet
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public void CopyScreen(ref STexture Texture)
|
public void CopyScreen(ref STexture Texture)
|
||||||
{
|
{
|
||||||
|
//FIXME
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a Screenshot of the current frame
|
||||||
|
/// </summary>
|
||||||
public void MakeScreenShot()
|
public void MakeScreenShot()
|
||||||
{
|
{
|
||||||
string file = "Screenshot_";
|
string file = "Screenshot_";
|
||||||
@@ -466,6 +566,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".bmp")))
|
while (File.Exists(Path.Combine(path, file + i.ToString("00000") + ".bmp")))
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
//create a surface of the frame
|
||||||
using (Surface surface = _Device.GetBackBuffer(0, 0))
|
using (Surface surface = _Device.GetBackBuffer(0, 0))
|
||||||
{
|
{
|
||||||
Bitmap screen = new Bitmap(Surface.ToStream(surface, ImageFileFormat.Bmp));
|
Bitmap screen = new Bitmap(Surface.ToStream(surface, ImageFileFormat.Bmp));
|
||||||
@@ -476,29 +577,74 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
_Mouse.Visible = true;
|
_Mouse.Visible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a line
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="a">The alpha value from 0-255</param>
|
||||||
|
/// <param name="r">The red value from 0-255</param>
|
||||||
|
/// <param name="g">The red value from 0-255</param>
|
||||||
|
/// <param name="b">The red value from 0-255</param>
|
||||||
|
/// <param name="w">The width of the line</param>
|
||||||
|
/// <param name="x1">The start x-value</param>
|
||||||
|
/// <param name="y1">The start y-value</param>
|
||||||
|
/// <param name="x2">The end x-value</param>
|
||||||
|
/// <param name="y2">The end y-value</param>
|
||||||
public void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2)
|
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);
|
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>
|
||||||
|
/// Draws a text string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Text">The text to be drawn</param>
|
||||||
|
/// <param name="x">The text's x-position</param>
|
||||||
|
/// <param name="y">The text's y-position</param>
|
||||||
|
/// <param name="h">The text's height</param>
|
||||||
public void DrawText(string Text, int x, int y, int h)
|
public void DrawText(string Text, int x, int y, int h)
|
||||||
{
|
{
|
||||||
DrawText(Text, x, y, h, 0f);
|
DrawText(Text, x, y, h, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a text string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Text">The text to be drawn</param>
|
||||||
|
/// <param name="x">The text's x-position</param>
|
||||||
|
/// <param name="y">The text's y-position</param>
|
||||||
|
/// <param name="h">The text's height</param>
|
||||||
|
/// <param name="z">The text's x-position</param>
|
||||||
public void DrawText(string Text, int x, int y, float h, float z)
|
public void DrawText(string Text, int x, int y, float h, float z)
|
||||||
{
|
{
|
||||||
CFonts.DrawText(Text, h, x, y, z, new SColorF(1f, 1f, 1f, 1f));
|
CFonts.DrawText(Text, h, x, y, z, new SColorF(1f, 1f, 1f, 1f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a colored rectangle
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="color">The color in which the rectangle will be drawn in</param>
|
||||||
|
/// <param name="rect">The coordinates in a SRectF struct</param>
|
||||||
public void DrawColor(SColorF color, SRectF rect)
|
public void DrawColor(SColorF color, SRectF rect)
|
||||||
{
|
{
|
||||||
|
//blankMap = new Bitmap(1, 1);
|
||||||
|
//Graphics g = Graphics.FromImage(blankMap);
|
||||||
|
//g.Clear(Color.White);
|
||||||
|
//g.Dispose();
|
||||||
|
//blankTexture = AddTexture(blankMap);
|
||||||
|
//blankMap.Dispose();
|
||||||
|
|
||||||
DrawTexture(blankTexture, rect, color);
|
DrawTexture(blankTexture, rect, color);
|
||||||
|
//RemoveTexture(ref blankTexture);
|
||||||
}
|
}
|
||||||
#endregion Basic Draw Methods
|
#endregion Basic Draw Methods
|
||||||
#region Textures
|
#region Textures
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a texture and stores it in the VRam
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="TexturePath">The texture's filepath</param>
|
||||||
|
/// <returns>A STexture object containing the added texture</returns>
|
||||||
public STexture AddTexture(string TexturePath)
|
public STexture AddTexture(string TexturePath)
|
||||||
{
|
{
|
||||||
if (System.IO.File.Exists(TexturePath))
|
if (System.IO.File.Exists(TexturePath))
|
||||||
@@ -519,18 +665,30 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
return new STexture(-1);
|
return new STexture(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculates the next power of two
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="n">The value of which the next power of two will be calculated</param>
|
||||||
|
/// <returns>The next power of two</returns>
|
||||||
private static float NextPowerOfTwo(float n)
|
private static float NextPowerOfTwo(float n)
|
||||||
{
|
{
|
||||||
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
if (n < 0) throw new ArgumentOutOfRangeException("n", "Must be positive.");
|
||||||
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
return (float)System.Math.Pow(2, System.Math.Ceiling(System.Math.Log((double)n, 2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a texture and stores it in the Vram
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bmp">The Bitmap of which the texute will be created from</param>
|
||||||
|
/// <param name="TexturePath">The path to the texture</param>
|
||||||
|
/// <returns>A STexture object containing the added texture</returns>
|
||||||
public STexture AddTexture(Bitmap bmp, string TexturePath)
|
public STexture AddTexture(Bitmap bmp, string TexturePath)
|
||||||
{
|
{
|
||||||
STexture texture = new STexture(-1);
|
STexture texture = new STexture(-1);
|
||||||
if (bmp.Height == 0 || bmp.Width == 0)
|
if (bmp.Height == 0 || bmp.Width == 0)
|
||||||
return texture;
|
return texture;
|
||||||
int MaxSize;
|
int MaxSize;
|
||||||
|
//Apply the right max size
|
||||||
switch (CConfig.TextureQuality)
|
switch (CConfig.TextureQuality)
|
||||||
{
|
{
|
||||||
case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST:
|
case ETextureQuality.TR_CONFIG_TEXTURE_LOWEST:
|
||||||
@@ -571,10 +729,13 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
texture.width = w;
|
texture.width = w;
|
||||||
texture.height = h;
|
texture.height = h;
|
||||||
|
|
||||||
|
//Older graphics card can only handle textures with sizes being powers of two
|
||||||
texture.w2 = (float)NextPowerOfTwo(w);
|
texture.w2 = (float)NextPowerOfTwo(w);
|
||||||
texture.h2 = (float)NextPowerOfTwo(h);
|
texture.h2 = (float)NextPowerOfTwo(h);
|
||||||
|
|
||||||
|
//Create a new Bitmap with the new sizes
|
||||||
Bitmap bmp2 = new Bitmap((int)texture.w2, (int)texture.h2);
|
Bitmap bmp2 = new Bitmap((int)texture.w2, (int)texture.h2);
|
||||||
|
//Scale the texture
|
||||||
Graphics g = Graphics.FromImage(bmp2);
|
Graphics g = Graphics.FromImage(bmp2);
|
||||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||||
@@ -584,12 +745,16 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
texture.width_ratio = 1f;
|
texture.width_ratio = 1f;
|
||||||
texture.height_ratio = 1f;
|
texture.height_ratio = 1f;
|
||||||
|
|
||||||
|
//Fill the new Bitmap with the texture data
|
||||||
BitmapData bmp_data = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
BitmapData bmp_data = bmp2.LockBits(new Rectangle(0, 0, bmp2.Width, bmp2.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
|
||||||
byte[] Data = new byte[4 * bmp2.Width * bmp2.Height];
|
byte[] Data = new byte[4 * bmp2.Width * bmp2.Height];
|
||||||
Marshal.Copy(bmp_data.Scan0, Data, 0, Data.Length);
|
Marshal.Copy(bmp_data.Scan0, Data, 0, Data.Length);
|
||||||
bmp2.UnlockBits(bmp_data);
|
bmp2.UnlockBits(bmp_data);
|
||||||
|
|
||||||
|
//Create a new texture in the managed pool, which does not need to be recreated on a lost device
|
||||||
|
//because a copy of the texture is hold in the Ram
|
||||||
Texture t = new Texture(_Device, (int)texture.w2, (int)texture.h2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
Texture t = new Texture(_Device, (int)texture.w2, (int)texture.h2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
||||||
|
//Lock the texture and fill it with the data
|
||||||
DataRectangle rect = t.LockRectangle(0, LockFlags.None);
|
DataRectangle rect = t.LockRectangle(0, LockFlags.None);
|
||||||
for (int i = 0; i < Data.Length; )
|
for (int i = 0; i < Data.Length; )
|
||||||
{
|
{
|
||||||
@@ -599,20 +764,29 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
rect.Data.Position += rect.Pitch;
|
rect.Data.Position += rect.Pitch;
|
||||||
}
|
}
|
||||||
t.UnlockRectangle(0);
|
t.UnlockRectangle(0);
|
||||||
_D3DTextures.Add(t);
|
|
||||||
bmp2.Dispose();
|
bmp2.Dispose();
|
||||||
bmp_data = null;
|
bmp_data = null;
|
||||||
|
|
||||||
// Add to Texture List
|
// Add to Texture List
|
||||||
texture.index = _D3DTextures.Count - 1;
|
|
||||||
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
||||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||||
texture.TexturePath = String.Empty;
|
texture.TexturePath = String.Empty;
|
||||||
|
lock (MutexTexture)
|
||||||
|
{
|
||||||
|
_D3DTextures.Add(t);
|
||||||
|
texture.index = _D3DTextures.Count - 1;
|
||||||
_Textures.Add(texture);
|
_Textures.Add(texture);
|
||||||
|
}
|
||||||
|
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds a texture and stores it in the Vram
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="bmp">The Bitmap of which the texute will be created from</param>
|
||||||
|
/// <returns>A STexture object containing the added texture</returns>
|
||||||
public STexture AddTexture(Bitmap bmp)
|
public STexture AddTexture(Bitmap bmp)
|
||||||
{
|
{
|
||||||
return AddTexture(bmp, String.Empty);
|
return AddTexture(bmp, String.Empty);
|
||||||
@@ -622,12 +796,27 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
{
|
{
|
||||||
byte[] PointerData = new Byte[4 * W * H];
|
byte[] PointerData = new Byte[4 * W * H];
|
||||||
Marshal.Copy(Data, PointerData, 0, PointerData.Length);
|
Marshal.Copy(Data, PointerData, 0, PointerData.Length);
|
||||||
return AddTexture(W, H , ref PointerData);
|
return AddTexture(W, H, ref PointerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
public STexture QuequeTexture(int W, int H, ref byte[] Data)
|
public STexture QuequeTexture(int W, int H, ref byte[] Data)
|
||||||
{
|
{
|
||||||
return AddTexture(W, H, ref Data);
|
STexture texture = new STexture(-1);
|
||||||
|
STextureQueque queque = new STextureQueque();
|
||||||
|
|
||||||
|
queque.data = Data;
|
||||||
|
queque.height = H;
|
||||||
|
queque.width = W;
|
||||||
|
|
||||||
|
lock (MutexTexture)
|
||||||
|
{
|
||||||
|
_D3DTextures.Add(null);
|
||||||
|
texture.index = _D3DTextures.Count - 1;
|
||||||
|
queque.ID = texture.index;
|
||||||
|
_Queque.Add(queque);
|
||||||
|
_Textures.Add(texture);
|
||||||
|
}
|
||||||
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
public STexture AddTexture(int W, int H, ref byte[] Data)
|
public STexture AddTexture(int W, int H, ref byte[] Data)
|
||||||
@@ -650,16 +839,26 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
rect.Data.Position += rect.Pitch;
|
rect.Data.Position += rect.Pitch;
|
||||||
}
|
}
|
||||||
t.UnlockRectangle(0);
|
t.UnlockRectangle(0);
|
||||||
_D3DTextures.Add(t);
|
|
||||||
|
|
||||||
texture.index = _D3DTextures.Count - 1;
|
|
||||||
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
||||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||||
texture.TexturePath = String.Empty;
|
texture.TexturePath = String.Empty;
|
||||||
|
|
||||||
|
lock (MutexTexture)
|
||||||
|
{
|
||||||
|
_D3DTextures.Add(t);
|
||||||
|
texture.index = _D3DTextures.Count - 1;
|
||||||
_Textures.Add(texture);
|
_Textures.Add(texture);
|
||||||
|
}
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the data of a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to update</param>
|
||||||
|
/// <param name="Data">A Pointer containing the data of which the texture should be updated</param>
|
||||||
|
/// <returns>True if succeeded</returns>
|
||||||
public bool UpdateTexture(ref STexture Texture, IntPtr Data)
|
public bool UpdateTexture(ref STexture Texture, IntPtr Data)
|
||||||
{
|
{
|
||||||
byte[] PointerData = new Byte[4 * (int)Texture.width * (int)Texture.height];
|
byte[] PointerData = new Byte[4 * (int)Texture.width * (int)Texture.height];
|
||||||
@@ -668,9 +867,15 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
return UpdateTexture(ref Texture, ref PointerData);
|
return UpdateTexture(ref Texture, ref PointerData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Updates the data of a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to update</param>
|
||||||
|
/// <param name="Data">A byte array containing the new texture's data</param>
|
||||||
|
/// <returns>True if succeeded</returns>
|
||||||
public bool UpdateTexture(ref STexture Texture, ref byte[] Data)
|
public bool UpdateTexture(ref STexture Texture, ref byte[] Data)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
|
||||||
{
|
{
|
||||||
DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.None);
|
DataRectangle rect = _D3DTextures[Texture.index].LockRectangle(0, LockFlags.None);
|
||||||
for (int i = 0; i < Data.Length; )
|
for (int i = 0; i < Data.Length; )
|
||||||
@@ -684,26 +889,44 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height);
|
Texture.height_ratio = Texture.height / NextPowerOfTwo(Texture.height);
|
||||||
Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width);
|
Texture.width_ratio = Texture.width / NextPowerOfTwo(Texture.width);
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool _TextureExists(STexture Texture)
|
/// <summary>
|
||||||
|
/// Checks if a texture exists
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to check</param>
|
||||||
|
/// <returns>True if the texture exists</returns>
|
||||||
|
private bool _TextureExists(ref STexture Texture)
|
||||||
{
|
{
|
||||||
if ((Texture.index > 0) && (_Textures.Count > 0))
|
lock (MutexTexture)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _Textures.Count; i++)
|
for (int i = 0; i < _Textures.Count; i++)
|
||||||
{
|
{
|
||||||
if (_Textures[i].index == Texture.index)
|
if (Texture.index == _Textures[i].index)
|
||||||
{
|
{
|
||||||
|
if (_Textures[i].index >= 0)
|
||||||
|
{
|
||||||
|
Texture = _Textures[i];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a texture from the Vram
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be removed</param>
|
||||||
public void RemoveTexture(ref STexture Texture)
|
public void RemoveTexture(ref STexture Texture)
|
||||||
|
{
|
||||||
|
lock (MutexTexture)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0))
|
if ((Texture.index >= 0) && (_Textures.Count > 0))
|
||||||
{
|
{
|
||||||
@@ -712,49 +935,88 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (_Textures[i].index == Texture.index)
|
if (_Textures[i].index == Texture.index)
|
||||||
{
|
{
|
||||||
_D3DTextures[Texture.index].Dispose();
|
_D3DTextures[Texture.index].Dispose();
|
||||||
|
_D3DTextures[Texture.index] = null;
|
||||||
_Textures.RemoveAt(i);
|
_Textures.RemoveAt(i);
|
||||||
Texture.index = -1;
|
Texture.index = -1;
|
||||||
GC.Collect();
|
Texture.ID = -1;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
public void DrawTexture(STexture Texture)
|
public void DrawTexture(STexture Texture)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
||||||
DrawTexture(Texture, Texture.rect, Texture.color);
|
DrawTexture(Texture, Texture.rect, Texture.color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
public void DrawTexture(STexture Texture, SRectF rect)
|
public void DrawTexture(STexture Texture, SRectF rect)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
||||||
DrawTexture(Texture, rect, Texture.color, false);
|
DrawTexture(Texture, rect, Texture.color, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
|
/// <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)
|
public void DrawTexture(STexture Texture, SRectF rect, SColorF color)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
||||||
DrawTexture(Texture, rect, color, false);
|
DrawTexture(Texture, rect, color, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
|
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
|
||||||
|
/// <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)
|
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
||||||
DrawTexture(Texture, rect, color, bounds, false);
|
DrawTexture(Texture, rect, color, bounds, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
|
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
|
||||||
|
/// <param name="mirrored">True if the texture should be mirrored</param>
|
||||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored)
|
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, bool mirrored)
|
||||||
{
|
{
|
||||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index))
|
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>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
|
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
|
||||||
|
/// <param name="bounds">A SRectF struct containing which part of the texture should be drawn</param>
|
||||||
|
/// <param name="mirrored">True if the texture should be mirrored</param>
|
||||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, SRectF bounds, bool 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))
|
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
|
||||||
{
|
{
|
||||||
|
//Calculate the position
|
||||||
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
|
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
|
||||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
|
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
|
||||||
float y1 = (bounds.Y - rect.Y) / rect.H * Texture.height_ratio;
|
float y1 = (bounds.Y - rect.Y) / rect.H * Texture.height_ratio;
|
||||||
@@ -772,6 +1034,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (y2 > Texture.height_ratio)
|
if (y2 > Texture.height_ratio)
|
||||||
y2 = Texture.height_ratio;
|
y2 = Texture.height_ratio;
|
||||||
|
|
||||||
|
//Calculate the size
|
||||||
float rx1 = rect.X;
|
float rx1 = rect.X;
|
||||||
float rx2 = rect.X + rect.W;
|
float rx2 = rect.X + rect.W;
|
||||||
float ry1 = rect.Y;
|
float ry1 = rect.Y;
|
||||||
@@ -789,7 +1052,8 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (ry2 > bounds.Y + bounds.H)
|
if (ry2 > bounds.Y + bounds.H)
|
||||||
ry2 = bounds.Y + bounds.H;
|
ry2 = bounds.Y + bounds.H;
|
||||||
|
|
||||||
rx1 -= 0.5f; // Align pixels
|
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||||
|
rx1 -= 0.5f;
|
||||||
ry1 -= 0.5f;
|
ry1 -= 0.5f;
|
||||||
rx2 -= 0.5f;
|
rx2 -= 0.5f;
|
||||||
ry2 -= 0.5f;
|
ry2 -= 0.5f;
|
||||||
@@ -801,6 +1065,8 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (color.G >= 1f)
|
if (color.G >= 1f)
|
||||||
color.G = 1f;
|
color.G = 1f;
|
||||||
|
|
||||||
|
//Apply rotation
|
||||||
|
//FIXME: Rotated textures get distorted when they hit the border of the window
|
||||||
if (rect.Rotation != 0)
|
if (rect.Rotation != 0)
|
||||||
{
|
{
|
||||||
rect.Rotation = rect.Rotation * (float)Math.PI / 180;
|
rect.Rotation = rect.Rotation * (float)Math.PI / 180;
|
||||||
@@ -812,12 +1078,18 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
Matrix rotation = Matrix.RotationZ(-rect.Rotation);
|
Matrix rotation = Matrix.RotationZ(-rect.Rotation);
|
||||||
Matrix translationB = Matrix.Translation(centerX, centerY, 0);
|
Matrix translationB = Matrix.Translation(centerX, centerY, 0);
|
||||||
|
|
||||||
|
//Multiplicate the matrices to get the real world matrix,
|
||||||
|
//First shift the texture into the center
|
||||||
|
//Rotate it and shift it back to the origin position
|
||||||
|
//Apply the originTranslation after
|
||||||
Matrix result = translationA * rotation * translationB * originTranslation;
|
Matrix result = translationA * rotation * translationB * originTranslation;
|
||||||
|
|
||||||
_Device.SetTransform(TransformState.World, result);
|
_Device.SetTransform(TransformState.World, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
||||||
|
|
||||||
|
//Create new vertices and write them into a vertexbuffer
|
||||||
DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
|
DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
|
||||||
if (!mirrored)
|
if (!mirrored)
|
||||||
{
|
{
|
||||||
@@ -839,9 +1111,12 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
}
|
}
|
||||||
_VertexBuffer.Unlock();
|
_VertexBuffer.Unlock();
|
||||||
stream.Dispose();
|
stream.Dispose();
|
||||||
|
//Set the texture
|
||||||
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
||||||
|
//Draw 2 triangles to build a quad
|
||||||
_Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
|
_Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
|
||||||
|
|
||||||
|
//Reapply old matrices if the texture was rotated
|
||||||
if (rect.Rotation != 0)
|
if (rect.Rotation != 0)
|
||||||
{
|
{
|
||||||
Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
||||||
@@ -850,39 +1125,95 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture to be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
|
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
|
||||||
|
/// <param name="begin">A Value ranging from 0 to 1 containing the beginning of the texture</param>
|
||||||
|
/// <param name="end">A Value ranging from 0 to 1 containing the ending of the texture</param>
|
||||||
|
|
||||||
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end)
|
public void DrawTexture(STexture Texture, SRectF rect, SColorF color, float begin, float end)
|
||||||
{
|
{
|
||||||
|
if (_TextureExists(ref Texture))
|
||||||
|
{
|
||||||
float x1 = 0f + begin * Texture.width_ratio;
|
float x1 = 0f + begin * Texture.width_ratio;
|
||||||
float x2 = Texture.width_ratio * end;
|
float x2 = Texture.width_ratio * end;
|
||||||
float y1 = 0f;
|
float y1 = 0f;
|
||||||
float y2 = Texture.height_ratio;
|
float y2 = Texture.height_ratio;
|
||||||
|
|
||||||
float rx1 = rect.X + begin* rect.W;
|
float rx1 = rect.X + begin * rect.W;
|
||||||
float rx2 = rect.X + end * rect.W;
|
float rx2 = rect.X + end * rect.W;
|
||||||
float ry1 = rect.Y;
|
float ry1 = rect.Y;
|
||||||
float ry2 = rect.Y + rect.H;
|
float ry2 = rect.Y + rect.H;
|
||||||
|
|
||||||
rx1 -= 0.5f; // Align pixels
|
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||||
|
rx1 -= 0.5f;
|
||||||
ry1 -= 0.5f;
|
ry1 -= 0.5f;
|
||||||
rx2 -= 0.5f;
|
rx2 -= 0.5f;
|
||||||
ry2 -= 0.5f;
|
ry2 -= 0.5f;
|
||||||
|
|
||||||
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
||||||
|
|
||||||
|
//Apply rotation
|
||||||
|
//FIXME: Rotated textures get distorted when they hit the border of the window
|
||||||
|
if (rect.Rotation != 0)
|
||||||
|
{
|
||||||
|
rect.Rotation = rect.Rotation * (float)Math.PI / 180;
|
||||||
|
float centerX = (rx1 + rx2) / 2f;
|
||||||
|
float centerY = -(ry1 + ry2) / 2f;
|
||||||
|
|
||||||
|
Matrix originTranslation = _Device.GetTransform(TransformState.World);
|
||||||
|
Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
|
||||||
|
Matrix rotation = Matrix.RotationZ(-rect.Rotation);
|
||||||
|
Matrix translationB = Matrix.Translation(centerX, centerY, 0);
|
||||||
|
|
||||||
|
//Multiplicate the matrices to get the real world matrix,
|
||||||
|
//First shift the texture into the center
|
||||||
|
//Rotate it and shift it back to the origin position
|
||||||
|
//Apply the originTranslation after
|
||||||
|
Matrix result = translationA * rotation * translationB * originTranslation;
|
||||||
|
|
||||||
|
_Device.SetTransform(TransformState.World, result);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Create new vertices and write them into a vertexbuffer
|
||||||
DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
|
DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
|
||||||
stream.WriteRange(new[] {
|
stream.WriteRange(new[] {
|
||||||
new TexturedColoredVertex(new Vector3(rx1, ry1*-1f, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()),
|
||||||
new TexturedColoredVertex(new Vector3(rx1, ry2*-1f, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
|
||||||
new TexturedColoredVertex(new Vector3(rx2, ry2*-1f, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
|
||||||
new TexturedColoredVertex(new Vector3(rx2, ry1*-1f, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()),
|
||||||
});
|
});
|
||||||
_VertexBuffer.Unlock();
|
_VertexBuffer.Unlock();
|
||||||
stream.Dispose();
|
stream.Dispose();
|
||||||
|
//Set the texture
|
||||||
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
||||||
|
//Draw 2 triangles to build a quad
|
||||||
_Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
|
_Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
|
||||||
|
|
||||||
|
//Reapply old matrices if the texture was rotated
|
||||||
|
if (rect.Rotation != 0)
|
||||||
|
{
|
||||||
|
Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
||||||
|
_Device.SetTransform(TransformState.World, originTranslation);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws a reflection of a texture
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Texture">The texture of which a reflection should be drawn</param>
|
||||||
|
/// <param name="rect">A SRectF struct containing the destination coordinates</param>
|
||||||
|
/// <param name="color">A SColorF struct containing a color which the texture will be colored in</param>
|
||||||
|
/// <param name="bounds">A SRectF struct containing which part of the texture should be drawn</param>
|
||||||
|
/// <param name="space">The space between the texture and the reflection</param>
|
||||||
|
/// <param name="height">The height of the reflection</param>
|
||||||
public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
public void DrawTextureReflection(STexture Texture, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
||||||
|
{
|
||||||
|
if (_TextureExists(ref Texture))
|
||||||
{
|
{
|
||||||
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f)
|
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f)
|
||||||
return;
|
return;
|
||||||
@@ -896,7 +1227,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (height > bounds.H)
|
if (height > bounds.H)
|
||||||
height = bounds.H;
|
height = bounds.H;
|
||||||
|
|
||||||
if (_TextureExists(Texture))
|
if (_TextureExists(ref Texture))
|
||||||
{
|
{
|
||||||
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
|
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
|
||||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
|
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
|
||||||
@@ -933,29 +1264,119 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
if (ry2 > bounds.Y + bounds.H + space + height)
|
if (ry2 > bounds.Y + bounds.H + space + height)
|
||||||
ry2 = bounds.Y + bounds.H + space + height;
|
ry2 = bounds.Y + bounds.H + space + height;
|
||||||
|
|
||||||
rx1 -= 0.5f; // Align pixels
|
//Align the pixels because Direct3D expects the pixels to be the left top corner
|
||||||
|
rx1 -= 0.5f;
|
||||||
ry1 -= 0.5f;
|
ry1 -= 0.5f;
|
||||||
rx2 -= 0.5f;
|
rx2 -= 0.5f;
|
||||||
ry2 -= 0.5f;
|
ry2 -= 0.5f;
|
||||||
|
|
||||||
DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
|
//Apply rotation
|
||||||
|
//FIXME: Rotated textures get distorted when they hit the border of the window
|
||||||
|
if (rect.Rotation != 0)
|
||||||
|
{
|
||||||
|
rect.Rotation = rect.Rotation * (float)Math.PI / 180;
|
||||||
|
float centerX = (rx1 + rx2) / 2f;
|
||||||
|
float centerY = -(ry1 + ry2) / 2f;
|
||||||
|
|
||||||
|
Matrix originTranslation = _Device.GetTransform(TransformState.World);
|
||||||
|
Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
|
||||||
|
Matrix rotation = Matrix.RotationZ(-rect.Rotation);
|
||||||
|
Matrix translationB = Matrix.Translation(centerX, centerY, 0);
|
||||||
|
|
||||||
|
//Multiplicate the matrices to get the real world matrix,
|
||||||
|
//First shift the texture into the center
|
||||||
|
//Rotate it and shift it back to the origin position
|
||||||
|
//Apply the originTranslation after
|
||||||
|
Matrix result = translationA * rotation * translationB * originTranslation;
|
||||||
|
|
||||||
|
_Device.SetTransform(TransformState.World, result);
|
||||||
|
}
|
||||||
|
|
||||||
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
Color c = Color.FromArgb((int)(color.A * 255 * CGraphics.GlobalAlpha), (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
||||||
Color t = Color.FromArgb(0, (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
Color transparent = Color.FromArgb(0, (int)(color.R * 255), (int)(color.G * 255), (int)(color.B * 255));
|
||||||
|
|
||||||
|
//Create new vertices and write them into a vertexbuffer
|
||||||
|
DataStream stream = _VertexBuffer.Lock(0, 0, LockFlags.Discard);
|
||||||
stream.WriteRange(new[] {
|
stream.WriteRange(new[] {
|
||||||
new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb()),
|
||||||
new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), t.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb()),
|
||||||
new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), t.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb()),
|
||||||
new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
|
new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb()),
|
||||||
});
|
});
|
||||||
_VertexBuffer.Unlock();
|
_VertexBuffer.Unlock();
|
||||||
stream.Dispose();
|
stream.Dispose();
|
||||||
|
//Set the texture
|
||||||
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
||||||
|
//Draw 2 triangles to build a quad
|
||||||
_Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
|
_Device.DrawPrimitives(PrimitiveType.TriangleFan, 0, 2);
|
||||||
|
|
||||||
|
//Reapply old matrices if the texture was rotated
|
||||||
|
if (rect.Rotation != 0)
|
||||||
|
{
|
||||||
|
Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
||||||
|
_Device.SetTransform(TransformState.World, originTranslation);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void CheckQueque()
|
||||||
|
{
|
||||||
|
lock (MutexTexture)
|
||||||
|
{
|
||||||
|
if (_Queque.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
STextureQueque q = _Queque[0];
|
||||||
|
STexture texture = new STexture(-1);
|
||||||
|
int index = -1;
|
||||||
|
for (int i = 0; i < _Textures.Count; i++)
|
||||||
|
{
|
||||||
|
if (_Textures[i].index == q.ID)
|
||||||
|
{
|
||||||
|
texture = _Textures[i];
|
||||||
|
index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (texture.index < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
texture.width = q.width;
|
||||||
|
texture.height = q.height;
|
||||||
|
texture.w2 = NextPowerOfTwo(texture.width);
|
||||||
|
texture.h2 = NextPowerOfTwo(texture.height);
|
||||||
|
|
||||||
|
texture.width_ratio = texture.width / texture.w2;
|
||||||
|
texture.height_ratio = texture.height / texture.h2;
|
||||||
|
|
||||||
|
Texture t = new Texture(_Device, (int)texture.w2, (int)texture.h2, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
||||||
|
DataRectangle rect = t.LockRectangle(0, LockFlags.None);
|
||||||
|
for (int i = 0; i < q.data.Length; )
|
||||||
|
{
|
||||||
|
rect.Data.Write(q.data, i, 4 * q.width);
|
||||||
|
i += 4 * q.width;
|
||||||
|
rect.Data.Position = rect.Data.Position - 4 * q.width;
|
||||||
|
rect.Data.Position += rect.Pitch;
|
||||||
|
}
|
||||||
|
t.UnlockRectangle(0);
|
||||||
|
_D3DTextures[q.ID] = t;
|
||||||
|
|
||||||
|
// Add to Texture List
|
||||||
|
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
||||||
|
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||||
|
texture.TexturePath = String.Empty;
|
||||||
|
|
||||||
|
_Textures[index] = texture;
|
||||||
|
_Queque.RemoveAt(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the count of current textures
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>The amount of textures</returns>
|
||||||
public int TextureCount()
|
public int TextureCount()
|
||||||
{
|
{
|
||||||
return _Textures.Count;
|
return _Textures.Count;
|
||||||
|
|||||||
@@ -65,6 +65,12 @@ namespace Vocaluxe.Screens
|
|||||||
if (KeyEvent.Handled)
|
if (KeyEvent.Handled)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!Char.IsControl(KeyEvent.Unicode))
|
||||||
|
{
|
||||||
|
JumpTo(KeyEvent.Unicode);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
switch (KeyEvent.Key)
|
switch (KeyEvent.Key)
|
||||||
{
|
{
|
||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
@@ -101,34 +107,34 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Keys.A:
|
//case Keys.A:
|
||||||
if (!_SearchActive && KeyEvent.Mod == Modifier.None)
|
// if (!_SearchActive && KeyEvent.Mod == Modifier.None)
|
||||||
{
|
// {
|
||||||
StartRandomAllSongs();
|
// StartRandomAllSongs();
|
||||||
}
|
// }
|
||||||
if (KeyEvent.Mod == Modifier.Ctrl)
|
// if (KeyEvent.Mod == Modifier.Ctrl)
|
||||||
{
|
// {
|
||||||
StartRandomVisibleSongs();
|
// StartRandomVisibleSongs();
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Keys.F:
|
//case Keys.F:
|
||||||
if (KeyEvent.Mod == Modifier.Ctrl){
|
// if (KeyEvent.Mod == Modifier.Ctrl){
|
||||||
if (_SearchActive)
|
// if (_SearchActive)
|
||||||
{
|
// {
|
||||||
_SearchActive = false;
|
// _SearchActive = false;
|
||||||
_SearchText = String.Empty;
|
// _SearchText = String.Empty;
|
||||||
ApplyNewSearchFilter(_SearchText);
|
// ApplyNewSearchFilter(_SearchText);
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
_SearchActive = true;
|
// _SearchActive = true;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case Keys.R:
|
case Keys.R:
|
||||||
if (CSongs.Category != -1)
|
if (CSongs.Category != -1 && KeyEvent.Mod == Modifier.Ctrl)
|
||||||
{
|
{
|
||||||
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
|
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
|
||||||
}
|
}
|
||||||
@@ -288,6 +294,23 @@ namespace Vocaluxe.Screens
|
|||||||
CGraphics.FadeTo(EScreens.ScreenNames);
|
CGraphics.FadeTo(EScreens.ScreenNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void JumpTo(char Letter)
|
||||||
|
{
|
||||||
|
int song = SongMenus[htSongMenus(SongMenu)].GetSelectedSong();
|
||||||
|
int id = -1;
|
||||||
|
if (song > -1 && song < CSongs.NumVisibleSongs)
|
||||||
|
{
|
||||||
|
id = CSongs.VisibleSongs[song].ID;
|
||||||
|
}
|
||||||
|
|
||||||
|
Vocaluxe.Lib.Song.CSong s = Array.Find<Vocaluxe.Lib.Song.CSong>(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (s != null && s.ID > -1)
|
||||||
|
{
|
||||||
|
id = s.ID;
|
||||||
|
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void ApplyNewSearchFilter(string NewFilterString)
|
private void ApplyNewSearchFilter(string NewFilterString)
|
||||||
{
|
{
|
||||||
int song = SongMenus[htSongMenus(SongMenu)].GetSelectedSong();
|
int song = SongMenus[htSongMenus(SongMenu)].GetSelectedSong();
|
||||||
|
|||||||
Reference in new issue
Block a user