Merge branch 'develop' into popup-control
This commit is contained in:
commit
faa7ebb964
17 files changed
+564
-392
No files matched your search
@@ -534,7 +534,7 @@
|
||||
<TextColor>TextColor</TextColor>
|
||||
<!--<TextSColor>: Selected text color from ColorScheme (high priority)-->
|
||||
<!--or <TextSR>, <TextSG>, <TextSB>, <TextSA> (lower priority)-->
|
||||
<TextSColor>TextColor</TextSColor>
|
||||
<TextSColor>TextSColor</TextSColor>
|
||||
<!--<TextH>: Text height-->
|
||||
<TextH>32,00</TextH>
|
||||
<!--<TextMaxW>: Maximum text width (if exists)-->
|
||||
|
||||
@@ -119,10 +119,7 @@
|
||||
<H>9</H>
|
||||
<!--<Color>: Static color from ColorScheme (high priority)-->
|
||||
<!--or <R>, <G>, <B>, <A> (lower priority)-->
|
||||
<R>0,68</R>
|
||||
<G>0,89</G>
|
||||
<B>0,97</B>
|
||||
<A>0,40</A>
|
||||
<Color>TimeBar</Color>
|
||||
<!--<Reflection> If exists:-->
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
@@ -138,7 +135,7 @@
|
||||
<H>9</H>
|
||||
<!--<Color>: Static color from ColorScheme (high priority)-->
|
||||
<!--or <R>, <G>, <B>, <A> (lower priority)-->
|
||||
<Color>StaticColor</Color>
|
||||
<Color>TimeBarSentence</Color>
|
||||
<!--<Reflection> If exists:-->
|
||||
<!-- <Space>: Reflection Space-->
|
||||
<!-- <Height>: Reflection Height-->
|
||||
|
||||
@@ -178,6 +178,18 @@
|
||||
<B>0,300</B>
|
||||
<A>1,000</A>
|
||||
</LyricSubColor>
|
||||
<TimeBar>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,500</A>
|
||||
</TimeBar>
|
||||
<TimeBarSentence>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,850</A>
|
||||
</TimeBarSentence>
|
||||
</ColorSchemes>
|
||||
<Skins>
|
||||
<BG_Default>[Blue]BG_Default.png</BG_Default>
|
||||
|
||||
@@ -178,6 +178,18 @@
|
||||
<B>0,300</B>
|
||||
<A>1,000</A>
|
||||
</LyricSubColor>
|
||||
<TimeBar>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,500</A>
|
||||
</TimeBar>
|
||||
<TimeBarSentence>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,850</A>
|
||||
</TimeBarSentence>
|
||||
</ColorSchemes>
|
||||
<Skins>
|
||||
<BG_Default>[Green]BG_Default.png</BG_Default>
|
||||
|
||||
@@ -178,6 +178,18 @@
|
||||
<B>0,300</B>
|
||||
<A>1,000</A>
|
||||
</LyricSubColor>
|
||||
<TimeBar>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,500</A>
|
||||
</TimeBar>
|
||||
<TimeBarSentence>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,850</A>
|
||||
</TimeBarSentence>
|
||||
</ColorSchemes>
|
||||
<Skins>
|
||||
<BG_Default>[Red]BG_Default.png</BG_Default>
|
||||
|
||||
@@ -178,6 +178,18 @@
|
||||
<B>0,300</B>
|
||||
<A>1,000</A>
|
||||
</LyricSubColor>
|
||||
<TimeBar>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,500</A>
|
||||
</TimeBar>
|
||||
<TimeBarSentence>
|
||||
<R>0,800</R>
|
||||
<G>0,950</G>
|
||||
<B>1,000</B>
|
||||
<A>0,850</A>
|
||||
</TimeBarSentence>
|
||||
</ColorSchemes>
|
||||
<Skins>
|
||||
<BG_Default>[Yellow]BG_Default.png</BG_Default>
|
||||
|
||||
@@ -162,7 +162,7 @@ namespace Vocaluxe.Base
|
||||
public static EDebugLevel DebugLevel = EDebugLevel.TR_CONFIG_OFF;
|
||||
|
||||
// Graphics
|
||||
public static ERenderer Renderer = ERenderer.TR_CONFIG_OPENGL;
|
||||
public static ERenderer Renderer = ERenderer.TR_CONFIG_DIRECT3D;
|
||||
public static ETextureQuality TextureQuality = ETextureQuality.TR_CONFIG_TEXTURE_MEDIUM;
|
||||
public static float MaxFPS = 60f;
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ namespace Vocaluxe.Base
|
||||
public const int iVersionSub = 0; // steps
|
||||
public const ERevision VersionRevision = ERevision.Beta;
|
||||
|
||||
public const int iBuild = 55; // Increase on every published version! Never Reset!
|
||||
public const int iBuild = 57; // Increase on every published version! Never Reset!
|
||||
|
||||
public const int iDatabaseHighscoreVersion = 1;
|
||||
public const int iDatabaseCoverVersion = 1;
|
||||
@@ -61,6 +61,7 @@ namespace Vocaluxe.Base
|
||||
public static int zFar = 100;
|
||||
|
||||
public static bool bFullScreen = false;
|
||||
public static int iVertexBufferElements = 10000;
|
||||
|
||||
public const string sIcon = "Vocaluxe.ico";
|
||||
public const string sLogo = "Logo.png";
|
||||
|
||||
@@ -497,7 +497,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
get
|
||||
{
|
||||
long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
|
||||
double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
long ticks = _Timer.ElapsedTicks;
|
||||
float dt = _Timer.ElapsedMilliseconds / 1000f;
|
||||
|
||||
@@ -577,7 +577,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
get
|
||||
{
|
||||
long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
|
||||
double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
long ticks = _STimer.ElapsedTicks;
|
||||
float dt = _STimer.ElapsedMilliseconds / 1000f;
|
||||
|
||||
@@ -613,7 +613,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
_STimer.Stop();
|
||||
|
||||
long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
|
||||
double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
long ticks = _STimer.ElapsedTicks;
|
||||
float dt = _STimer.ElapsedMilliseconds / 1000f;
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
private static Stopwatch _Stopwatch = new Stopwatch();
|
||||
private static float _fps = 0.0f;
|
||||
private static long nanosecPerTick = (1000L * 1000L * 1000L) / Stopwatch.Frequency;
|
||||
private static double nanosecPerTick = (1000.0 * 1000.0 * 1000.0) / Stopwatch.Frequency;
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
@@ -149,7 +149,7 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
long ticks = _Stopwatch.ElapsedTicks;
|
||||
if (Stopwatch.IsHighResolution && ticks != 0)
|
||||
return (float)(((double)nanosecPerTick * (double)ticks) / (1000.0 * 1000.0));
|
||||
return (float)((nanosecPerTick * ticks) / (1000.0 * 1000.0));
|
||||
else
|
||||
return (float)_Stopwatch.ElapsedMilliseconds;
|
||||
}
|
||||
|
||||
+284
-231
@@ -34,22 +34,25 @@ namespace Vocaluxe.Lib.Draw
|
||||
private Size _OldSize;
|
||||
private Size _SizeBeforeMinimize;
|
||||
|
||||
private List<STexture> _Textures;
|
||||
private Dictionary<int, STexture> _Textures;
|
||||
private List<Texture> _D3DTextures;
|
||||
private List<STextureQueque> _Queque;
|
||||
|
||||
private Object MutexTexture = new Object();
|
||||
|
||||
private VertexBuffer _VertexBuffer;
|
||||
private IndexBuffer _IndexBuffer;
|
||||
|
||||
private int h = 1;
|
||||
private int w = 1;
|
||||
private int y = 0;
|
||||
private int x = 0;
|
||||
|
||||
private Bitmap blankMap;
|
||||
private STexture blankTexture;
|
||||
private Texture transparentTexture;
|
||||
|
||||
private Queue<TexturedColoredVertex> _Vertices;
|
||||
private Queue<Texture> _VerticesTextures;
|
||||
private Queue<Matrix> _VerticesRotationMatrices;
|
||||
|
||||
#endregion private vars
|
||||
|
||||
@@ -59,13 +62,24 @@ namespace Vocaluxe.Lib.Draw
|
||||
public CDirect3D()
|
||||
{
|
||||
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
|
||||
_Textures = new List<STexture>();
|
||||
_Textures = new Dictionary<int, STexture>();
|
||||
_D3DTextures = new List<Texture>();
|
||||
_Queque = new List<STextureQueque>();
|
||||
|
||||
_Vertices = new Queue<TexturedColoredVertex>();
|
||||
_VerticesTextures = new Queue<Texture>();
|
||||
_VerticesRotationMatrices = new Queue<Matrix>();
|
||||
|
||||
_Keys = new CKeys();
|
||||
_D3D = new Direct3D();
|
||||
|
||||
if (_D3D == null)
|
||||
{
|
||||
MessageBox.Show("No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
CLog.LogError("No DirectX runtimes were found, please download and install them from http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
}
|
||||
|
||||
this.Paint += new PaintEventHandler(this.OnPaintEvent);
|
||||
this.Closing += new CancelEventHandler(this.OnClosingEvent);
|
||||
this.Resize += new EventHandler(this.OnResizeEvent);
|
||||
@@ -160,18 +174,14 @@ namespace Vocaluxe.Lib.Draw
|
||||
flags = CreateFlags.SoftwareVertexProcessing;
|
||||
_Device = new Device(_D3D, _D3D.Adapters.DefaultAdapter.Adapter, DeviceType.Hardware, Handle, flags, _PresentParameters);
|
||||
|
||||
if (_Device.Disposed || _D3D.Disposed || _Device == null || _D3D == null)
|
||||
{
|
||||
MessageBox.Show("Something went wrong with device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
CLog.LogError("Something went wrong with device creating, please check if your DirectX redistributables and grafic card drivers are up to date. You can download the DirectX runtimes at http://www.microsoft.com/download/en/details.aspx?id=8109");
|
||||
Environment.Exit(Environment.ExitCode);
|
||||
}
|
||||
|
||||
this.CenterToScreen();
|
||||
|
||||
//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);
|
||||
g.Clear(Color.White);
|
||||
g.Dispose();
|
||||
blankTexture = AddTexture(blankMap);
|
||||
|
||||
transparentTexture = new Texture(_Device, 1, 1, 0, Usage.None, Format.A8R8G8B8, Pool.Managed);
|
||||
blankMap.Dispose();
|
||||
}
|
||||
|
||||
#region form events
|
||||
@@ -198,10 +208,32 @@ namespace Vocaluxe.Lib.Draw
|
||||
protected override void OnResize(EventArgs e)
|
||||
{
|
||||
base.OnResize(e);
|
||||
this.ClientSize = this.ClientSize;
|
||||
RResize();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
switch (m.Msg)
|
||||
{
|
||||
case 0x112: // WM_SYSCOMMAND
|
||||
switch ((int)m.WParam & 0xFFF0)
|
||||
{
|
||||
case 0xF100: // SC_KEYMENU
|
||||
m.Result = IntPtr.Zero;
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion form events
|
||||
|
||||
#region resize
|
||||
/// <summary>
|
||||
/// Resizes the viewport
|
||||
/// </summary>
|
||||
@@ -257,15 +289,29 @@ namespace Vocaluxe.Lib.Draw
|
||||
//Real fullscreen could be gained setting _PresentParameters.Windowed = true
|
||||
//And calling Reset() and Init() after
|
||||
_OldSize = this.ClientSize;
|
||||
this.ClientSize = new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
|
||||
|
||||
int ScreenNr = 0;
|
||||
for (int i = 0; i < Screen.AllScreens.Length; i++)
|
||||
{
|
||||
Screen scr = Screen.AllScreens[i];
|
||||
if (scr.Bounds.Top <= this.Top && scr.Bounds.Left <= this.Left)
|
||||
ScreenNr = i;
|
||||
}
|
||||
|
||||
this.ClientSize = new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height);
|
||||
this.FormBorderStyle = FormBorderStyle.None;
|
||||
CenterToScreen();
|
||||
_fullscreen = true;
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_ON;
|
||||
RResize();
|
||||
|
||||
Cursor.Hide();
|
||||
_Mouse.Visible = true;
|
||||
if (this.WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
RResize();
|
||||
this.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
else
|
||||
RResize();
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
@@ -280,11 +326,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
_fullscreen = false;
|
||||
CConfig.FullScreen = EOffOn.TR_CONFIG_OFF;
|
||||
|
||||
Cursor.Hide();
|
||||
_Mouse.Visible = true;
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
#endregion resize
|
||||
|
||||
#region mouse event handlers
|
||||
private void OnMouseMove(object sender, MouseEventArgs e)
|
||||
@@ -345,7 +389,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
#endregion keyboard event handlers
|
||||
|
||||
#region implementation
|
||||
|
||||
#region main stuff
|
||||
/// <summary>
|
||||
/// Inits the Device
|
||||
/// </summary>
|
||||
@@ -357,7 +401,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
this.Text = CSettings.GetFullVersionText();
|
||||
Matrix translate = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
||||
Matrix projection = Matrix.OrthoOffCenterLH(-CSettings.iRenderW / 2, CSettings.iRenderW / 2, -CSettings.iRenderH / 2, CSettings.iRenderH / 2, CSettings.zNear, CSettings.zFar);
|
||||
_VertexBuffer = new VertexBuffer(_Device, 4 * Marshal.SizeOf(typeof(TexturedColoredVertex)), Usage.WriteOnly | Usage.Dynamic, VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
|
||||
_VertexBuffer = new VertexBuffer(_Device, CSettings.iVertexBufferElements * (4 * Marshal.SizeOf(typeof(TexturedColoredVertex))), Usage.WriteOnly | Usage.Dynamic, VertexFormat.Position | VertexFormat.Texture1 | VertexFormat.Diffuse, Pool.Default);
|
||||
_Device.SetStreamSource(0, _VertexBuffer, 0, Marshal.SizeOf(typeof(TexturedColoredVertex)));
|
||||
_Device.VertexDeclaration = TexturedColoredVertex.GetDeclaration(_Device);
|
||||
_Device.SetTransform(TransformState.Projection, projection);
|
||||
@@ -377,6 +421,31 @@ namespace Vocaluxe.Lib.Draw
|
||||
_Device.SetTextureStageState(0, TextureStage.AlphaArg1, TextureArgument.Texture);
|
||||
_Device.SetTextureStageState(0, TextureStage.AlphaArg2, TextureArgument.Diffuse);
|
||||
_Device.SetTextureStageState(0, TextureStage.AlphaOperation, TextureOperation.Modulate);
|
||||
|
||||
Int16[] indices = new Int16[6];
|
||||
indices[0] = 0;
|
||||
indices[1] = 1;
|
||||
indices[2] = 2;
|
||||
indices[3] = 0;
|
||||
indices[4] = 2;
|
||||
indices[5] = 3;
|
||||
|
||||
_IndexBuffer = new IndexBuffer(_Device, 6 * sizeof(int), Usage.WriteOnly, Pool.Managed, true);
|
||||
|
||||
DataStream stream = _IndexBuffer.Lock(0, 0, LockFlags.None);
|
||||
stream.WriteRange(indices);
|
||||
_IndexBuffer.Unlock();
|
||||
_Device.Indices = _IndexBuffer;
|
||||
|
||||
//This creates a new white texture and adds it to the texture pool
|
||||
//This texture is used for the DrawRect method
|
||||
Bitmap blankMap = new Bitmap(1, 1);
|
||||
Graphics g = Graphics.FromImage(blankMap);
|
||||
g.Clear(Color.White);
|
||||
g.Dispose();
|
||||
blankTexture = AddTexture(blankMap);
|
||||
|
||||
blankMap.Dispose();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@@ -409,6 +478,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
_Device.BeginScene();
|
||||
CheckQueque();
|
||||
_Run = _Run && CGraphics.Draw();
|
||||
RenderVertexBuffer();
|
||||
//We finished drawing the frame
|
||||
_Device.EndScene();
|
||||
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
|
||||
@@ -440,7 +510,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (CTime.IsRunning())
|
||||
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
|
||||
|
||||
if (delay >= 1)
|
||||
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
|
||||
System.Threading.Thread.Sleep(delay);
|
||||
//Calculate the FPS Rate and restart the timer after a frame
|
||||
CTime.CalculateFPS();
|
||||
@@ -459,6 +529,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
//Dispose all objects in the default pool, those need to be recreated
|
||||
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
|
||||
_VertexBuffer.Dispose();
|
||||
_IndexBuffer.Dispose();
|
||||
_Device.Reset(_PresentParameters);
|
||||
}
|
||||
|
||||
@@ -471,11 +542,12 @@ namespace Vocaluxe.Lib.Draw
|
||||
//Dispose all textures
|
||||
for (int i = 0; i < _D3DTextures.Count; i++)
|
||||
{
|
||||
if(_D3DTextures[i] != null)
|
||||
if (_D3DTextures[i] != null)
|
||||
_D3DTextures[i].Dispose();
|
||||
}
|
||||
TexturedColoredVertex.GetDeclaration(_Device).Dispose();
|
||||
_VertexBuffer.Dispose();
|
||||
_IndexBuffer.Dispose();
|
||||
_Device.Dispose();
|
||||
_D3D.Dispose();
|
||||
return true;
|
||||
@@ -523,6 +595,55 @@ namespace Vocaluxe.Lib.Draw
|
||||
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a quad a list which will be added and rendered to the vertexbuffer when calling RenderToVertexBuffer to reduce vertexbuffer calls each frame to a minimum
|
||||
/// </summary>
|
||||
/// <param name="vertices">A TexturedColoredVertex array containg 4 vertices</param>
|
||||
/// <param name="tex">The texture the vertex should be textured with</param>
|
||||
/// <param name="rotation">The vertices' rotation</param>
|
||||
private void AddToVertexBuffer(TexturedColoredVertex[] vertices, Texture tex, Matrix rotation)
|
||||
{
|
||||
//The vertexbuffer is full, so we need to flush it before we can continue
|
||||
if (_Vertices.Count >= CSettings.iVertexBufferElements)
|
||||
RenderVertexBuffer();
|
||||
_Vertices.Enqueue(vertices[0]);
|
||||
_Vertices.Enqueue(vertices[1]);
|
||||
_Vertices.Enqueue(vertices[2]);
|
||||
_Vertices.Enqueue(vertices[3]);
|
||||
_VerticesTextures.Enqueue(tex);
|
||||
_VerticesRotationMatrices.Enqueue(rotation);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Renders the vertex buffer
|
||||
/// </summary>
|
||||
private void RenderVertexBuffer()
|
||||
{
|
||||
if (_Vertices.Count > 0)
|
||||
{
|
||||
//The vertex buffer locks are slow actions, its better to lock once per frame and write all vertices to the buffer at once
|
||||
DataStream stream = _VertexBuffer.Lock(0, _Vertices.Count * Marshal.SizeOf(typeof(TexturedColoredVertex)), LockFlags.Discard);
|
||||
stream.WriteRange<TexturedColoredVertex>(_Vertices.ToArray());
|
||||
_VertexBuffer.Unlock();
|
||||
stream.Dispose();
|
||||
|
||||
for (int i = 0; i < _Vertices.Count; i += 4)
|
||||
{
|
||||
//Apply rotation
|
||||
_Device.SetTransform(TransformState.World, _VerticesRotationMatrices.Dequeue());
|
||||
//Apply texture
|
||||
_Device.SetTexture(0, _VerticesTextures.Dequeue());
|
||||
//Draw 2 triangles from vertexbuffer
|
||||
_Device.DrawIndexedPrimitives(PrimitiveType.TriangleList, i, 0, 4, 0, 2);
|
||||
}
|
||||
//Clear the queues for the next frame
|
||||
_Vertices.Clear();
|
||||
_VerticesTextures.Clear();
|
||||
_VerticesRotationMatrices.Clear();
|
||||
}
|
||||
}
|
||||
#endregion main stuff
|
||||
|
||||
#region Basic Draw Methods
|
||||
|
||||
/// <summary>
|
||||
@@ -534,24 +655,51 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not implemented yet
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// Copies the current frame into a texture
|
||||
/// <returns>A texture holding the current frame</returns>
|
||||
public STexture CopyScreen()
|
||||
{
|
||||
//FIXME
|
||||
STexture texture = new STexture(-1);
|
||||
|
||||
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
|
||||
Texture tex = new Texture(_Device, _PresentParameters.BackBufferWidth, _PresentParameters.BackBufferHeight, 0, Usage.AutoGenerateMipMap, Format.A8R8G8B8, Pool.Managed);
|
||||
Surface textureSurface = tex.GetSurfaceLevel(0);
|
||||
Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0);
|
||||
backbufferSurface.Dispose();
|
||||
_D3DTextures.Add(tex);
|
||||
|
||||
texture.color = new SColorF(1f, 1f, 1f, 1f);
|
||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||
texture.width = w;
|
||||
texture.height = h;
|
||||
texture.w2 = NextPowerOfTwo(texture.width);
|
||||
texture.h2 = NextPowerOfTwo(texture.height);
|
||||
texture.index = _D3DTextures.Count - 1;
|
||||
|
||||
lock (MutexTexture)
|
||||
{
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Not implemented yet
|
||||
/// Copies the current frame into a texture
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <param name="Texture">The texture in which the frame is copied to</param>
|
||||
public void CopyScreen(ref STexture Texture)
|
||||
{
|
||||
//FIXME
|
||||
return;
|
||||
if (!_TextureExists(ref Texture) || (Texture.width != GetScreenWidth()) || (Texture.height != GetScreenHeight()))
|
||||
{
|
||||
RemoveTexture(ref Texture);
|
||||
Texture = CopyScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
Surface backbufferSurface = _Device.GetBackBuffer(0, 0);
|
||||
Surface textureSurface = _D3DTextures[Texture.index].GetSurfaceLevel(0);
|
||||
Surface.FromSurface(textureSurface, backbufferSurface, Filter.Default, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -627,18 +775,11 @@ namespace Vocaluxe.Lib.Draw
|
||||
/// <param name="rect">The coordinates in a SRectF struct</param>
|
||||
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);
|
||||
//RemoveTexture(ref blankTexture);
|
||||
}
|
||||
#endregion Basic Draw Methods
|
||||
#region Textures
|
||||
#region adding
|
||||
|
||||
/// <summary>
|
||||
/// Adds a texture and stores it in the VRam
|
||||
@@ -665,17 +806,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
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)
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a texture and stores it in the Vram
|
||||
/// </summary>
|
||||
@@ -764,7 +894,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
rect.Data.Position += rect.Pitch;
|
||||
}
|
||||
t.UnlockRectangle(0);
|
||||
|
||||
|
||||
bmp2.Dispose();
|
||||
bmp_data = null;
|
||||
|
||||
@@ -776,9 +906,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
_D3DTextures.Add(t);
|
||||
texture.index = _D3DTextures.Count - 1;
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
@@ -807,6 +936,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
queque.data = Data;
|
||||
queque.height = H;
|
||||
queque.width = W;
|
||||
texture.height = H;
|
||||
texture.width = W;
|
||||
|
||||
lock (MutexTexture)
|
||||
{
|
||||
@@ -814,7 +945,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
texture.index = _D3DTextures.Count - 1;
|
||||
queque.ID = texture.index;
|
||||
_Queque.Add(queque);
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
@@ -848,11 +979,13 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
_D3DTextures.Add(t);
|
||||
texture.index = _D3DTextures.Count - 1;
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
return texture;
|
||||
}
|
||||
#endregion adding
|
||||
|
||||
#region updating
|
||||
/// <summary>
|
||||
/// Updates the data of a texture
|
||||
/// </summary>
|
||||
@@ -894,6 +1027,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
else
|
||||
return false;
|
||||
}
|
||||
#endregion updating
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a texture exists
|
||||
@@ -904,16 +1038,12 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
lock (MutexTexture)
|
||||
{
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
if (_Textures.ContainsKey(Texture.index))
|
||||
{
|
||||
if (Texture.index == _Textures[i].index)
|
||||
if (_Textures[Texture.index].index >= 0)
|
||||
{
|
||||
if (_Textures[i].index >= 0)
|
||||
{
|
||||
Texture = _Textures[i];
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
Texture = _Textures[Texture.index];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -930,21 +1060,16 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0))
|
||||
{
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
{
|
||||
if (_Textures[i].index == Texture.index)
|
||||
{
|
||||
_D3DTextures[Texture.index].Dispose();
|
||||
_D3DTextures[Texture.index] = null;
|
||||
_Textures.RemoveAt(i);
|
||||
Texture.index = -1;
|
||||
Texture.ID = -1;
|
||||
}
|
||||
}
|
||||
_D3DTextures[Texture.index].Dispose();
|
||||
_D3DTextures[Texture.index] = null;
|
||||
_Textures.Remove(Texture.index);
|
||||
Texture.index = -1;
|
||||
Texture.ID = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region drawing
|
||||
/// <summary>
|
||||
/// Draws a texture
|
||||
/// </summary>
|
||||
@@ -1016,6 +1141,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
if ((Texture.index >= 0) && (_Textures.Count > 0) && (_D3DTextures.Count > Texture.index) && _TextureExists(ref Texture))
|
||||
{
|
||||
if (_D3DTextures[Texture.index] == null)
|
||||
return;
|
||||
|
||||
//Calculate the position
|
||||
float x1 = (bounds.X - rect.X) / rect.W * Texture.width_ratio;
|
||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * Texture.width_ratio;
|
||||
@@ -1058,69 +1186,34 @@ namespace Vocaluxe.Lib.Draw
|
||||
rx2 -= 0.5f;
|
||||
ry2 -= 0.5f;
|
||||
|
||||
if (color.R >= 1f)
|
||||
color.R = 1f;
|
||||
if (color.B >= 1f)
|
||||
color.B = 1f;
|
||||
if (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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
if (color.A > 1)
|
||||
color.A = 1;
|
||||
if (color.R > 1)
|
||||
color.R = 1;
|
||||
if (color.G > 1)
|
||||
color.G = 1;
|
||||
if (color.B > 1)
|
||||
color.B = 1;
|
||||
|
||||
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);
|
||||
if (!mirrored)
|
||||
{
|
||||
stream.WriteRange(new[] {
|
||||
new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()),
|
||||
new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, 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, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()),
|
||||
});
|
||||
TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
|
||||
vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
|
||||
vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
vert[3] = new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb());
|
||||
AddToVertexBuffer(vert, _D3DTextures[Texture.index], CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
else
|
||||
{
|
||||
stream.WriteRange(new[] {
|
||||
new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb()),
|
||||
new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -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, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y1), c.ToArgb()),
|
||||
});
|
||||
}
|
||||
_VertexBuffer.Unlock();
|
||||
stream.Dispose();
|
||||
//Set the texture
|
||||
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
||||
//Draw 2 triangles to build a quad
|
||||
_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);
|
||||
TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
|
||||
vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y1), c.ToArgb());
|
||||
vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, -y2), c.ToArgb());
|
||||
vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y2), c.ToArgb());
|
||||
vert[3] = new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, -y1), c.ToArgb());
|
||||
AddToVertexBuffer(vert, _D3DTextures[Texture.index], CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1138,6 +1231,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
if (_TextureExists(ref Texture))
|
||||
{
|
||||
if (_D3DTextures[Texture.index] == null)
|
||||
return;
|
||||
|
||||
float x1 = 0f + begin * Texture.width_ratio;
|
||||
float x2 = Texture.width_ratio * end;
|
||||
float y1 = 0f;
|
||||
@@ -1156,49 +1252,12 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
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);
|
||||
stream.WriteRange(new[] {
|
||||
new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb()),
|
||||
new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, 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, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb()),
|
||||
});
|
||||
_VertexBuffer.Unlock();
|
||||
stream.Dispose();
|
||||
//Set the texture
|
||||
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
||||
//Draw 2 triangles to build a quad
|
||||
_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);
|
||||
}
|
||||
TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
|
||||
vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), c.ToArgb());
|
||||
vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
vert[3] = new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), c.ToArgb());
|
||||
AddToVertexBuffer(vert, _D3DTextures[Texture.index], CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1215,6 +1274,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
if (_TextureExists(ref Texture))
|
||||
{
|
||||
if (_D3DTextures[Texture.index] == null)
|
||||
return;
|
||||
|
||||
if (rect.W == 0f || rect.H == 0f || bounds.H == 0f || bounds.W == 0f || color.A == 0f || height <= 0f)
|
||||
return;
|
||||
|
||||
@@ -1270,55 +1332,19 @@ namespace Vocaluxe.Lib.Draw
|
||||
rx2 -= 0.5f;
|
||||
ry2 -= 0.5f;
|
||||
|
||||
//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 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[] {
|
||||
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), transparent.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()),
|
||||
});
|
||||
_VertexBuffer.Unlock();
|
||||
stream.Dispose();
|
||||
//Set the texture
|
||||
_Device.SetTexture(0, _D3DTextures[Texture.index]);
|
||||
//Draw 2 triangles to build a quad
|
||||
_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);
|
||||
}
|
||||
TexturedColoredVertex[] vert = new TexturedColoredVertex[4];
|
||||
vert[0] = new TexturedColoredVertex(new Vector3(rx1, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x1, y2), c.ToArgb());
|
||||
vert[1] = new TexturedColoredVertex(new Vector3(rx1, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x1, y1), transparent.ToArgb());
|
||||
vert[2] = new TexturedColoredVertex(new Vector3(rx2, -ry2, rect.Z + CGraphics.ZOffset), new Vector2(x2, y1), transparent.ToArgb());
|
||||
vert[3] = new TexturedColoredVertex(new Vector3(rx2, -ry1, rect.Z + CGraphics.ZOffset), new Vector2(x2, y2), c.ToArgb());
|
||||
AddToVertexBuffer(vert, _D3DTextures[Texture.index], CalculateRotationMatrix(rect.Rotation, rx1, rx2, ry1, ry2));
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion drawing
|
||||
|
||||
private void CheckQueque()
|
||||
{
|
||||
@@ -1329,17 +1355,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
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 (_Textures.ContainsKey(q.ID))
|
||||
texture = _Textures[q.ID];
|
||||
if (texture.index < 0)
|
||||
return;
|
||||
|
||||
@@ -1368,7 +1385,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||
texture.TexturePath = String.Empty;
|
||||
|
||||
_Textures[index] = texture;
|
||||
_Textures[texture.index] = texture;
|
||||
_Queque.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
@@ -1384,6 +1401,42 @@ namespace Vocaluxe.Lib.Draw
|
||||
#endregion Textures
|
||||
#endregion implementation
|
||||
|
||||
#region utility
|
||||
/// <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)
|
||||
{
|
||||
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)));
|
||||
}
|
||||
|
||||
private Matrix CalculateRotationMatrix(float rot, float rx1, float rx2, float ry1, float ry2)
|
||||
{
|
||||
Matrix originTranslation = Matrix.Translation(new Vector3(-CSettings.iRenderW / 2, CSettings.iRenderH / 2, 0));
|
||||
if (rot != 0)
|
||||
{
|
||||
float rotation = rot * (float)Math.PI / 180;
|
||||
float centerX = (rx1 + rx2) / 2f;
|
||||
float centerY = -(ry1 + ry2) / 2f;
|
||||
|
||||
Matrix translationA = Matrix.Translation(-centerX, -centerY, 0);
|
||||
Matrix rotationMat = Matrix.RotationZ(-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 * rotationMat * translationB * originTranslation;
|
||||
return result;
|
||||
}
|
||||
return originTranslation;
|
||||
}
|
||||
#endregion utility
|
||||
|
||||
#region TexturedColoredVertex
|
||||
public struct TexturedColoredVertex
|
||||
{
|
||||
|
||||
@@ -153,6 +153,27 @@ namespace Vocaluxe.Lib.Draw
|
||||
_Run = false;
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
switch (m.Msg)
|
||||
{
|
||||
case 0x112: // WM_SYSCOMMAND
|
||||
switch ((int)m.WParam & 0xFFF0)
|
||||
{
|
||||
case 0xF100: // SC_KEYMENU
|
||||
m.Result = IntPtr.Zero;
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnKeyDownEvent(object sender, System.Windows.Forms.KeyEventArgs e)
|
||||
{
|
||||
_Keys.KeyDown(e);
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
private SClientRect _restore;
|
||||
private bool _fullscreen = false;
|
||||
|
||||
private List<STexture> _Textures;
|
||||
private Dictionary<int, STexture> _Textures;
|
||||
private Queue<int> _IDs;
|
||||
private List<STextureQueque> _Queque;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
this.Icon = new System.Drawing.Icon(Path.Combine(System.Environment.CurrentDirectory, CSettings.sIcon));
|
||||
|
||||
_Textures = new List<STexture>();
|
||||
_Textures = new Dictionary<int, STexture>();
|
||||
_Queque = new List<STextureQueque>();
|
||||
_IDs = new Queue<int>(1000000);
|
||||
|
||||
@@ -121,7 +121,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
control.MouseEnter += new EventHandler(this.OnMouseEnter);
|
||||
|
||||
this.ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH);
|
||||
//this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.Opaque, true);
|
||||
this.CenterToScreen();
|
||||
}
|
||||
|
||||
@@ -285,8 +284,15 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
this.DesktopBounds = new Rectangle(Screen.AllScreens[ScreenNr].Bounds.Location,
|
||||
new Size(Screen.AllScreens[ScreenNr].Bounds.Width, Screen.AllScreens[ScreenNr].Bounds.Height));
|
||||
this.TopMost = true;
|
||||
this.Show();
|
||||
|
||||
if (this.WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
this.WindowState = FormWindowState.Normal;
|
||||
RResize();
|
||||
this.WindowState = FormWindowState.Maximized;
|
||||
}
|
||||
else
|
||||
RResize();
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
@@ -299,8 +305,6 @@ namespace Vocaluxe.Lib.Draw
|
||||
this.FormBorderStyle = FormBorderStyle.Sizable;
|
||||
this.DesktopBounds = new Rectangle(_restore.location, new Size(_restore.width, _restore.height));
|
||||
|
||||
this.TopMost = false;
|
||||
|
||||
CConfig.SaveConfig();
|
||||
}
|
||||
#endregion Helpers
|
||||
@@ -333,6 +337,27 @@ namespace Vocaluxe.Lib.Draw
|
||||
control.ClientSize = this.ClientSize;
|
||||
RResize();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
switch (m.Msg)
|
||||
{
|
||||
case 0x112: // WM_SYSCOMMAND
|
||||
switch ((int)m.WParam & 0xFFF0)
|
||||
{
|
||||
case 0xF100: // SC_KEYMENU
|
||||
m.Result = IntPtr.Zero;
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
base.WndProc(ref m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion form events
|
||||
|
||||
#region mouse event handlers
|
||||
@@ -419,7 +444,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
|
||||
#region implementation
|
||||
|
||||
#region main stuff
|
||||
public bool Init()
|
||||
{
|
||||
this.Text = CSettings.GetFullVersionText();
|
||||
@@ -448,7 +473,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
CSettings.bFullScreen = true;
|
||||
EnterFullScreen();
|
||||
}
|
||||
|
||||
|
||||
while (_Run)
|
||||
{
|
||||
Application.DoEvents();
|
||||
@@ -456,12 +481,11 @@ namespace Vocaluxe.Lib.Draw
|
||||
if (_Run)
|
||||
{
|
||||
ClearScreen();
|
||||
|
||||
_Run = _Run && CGraphics.Draw();
|
||||
|
||||
_Run = CGraphics.UpdateGameLogic(_Keys, _Mouse);
|
||||
control.SwapBuffers();
|
||||
|
||||
|
||||
if ((CSettings.bFullScreen && !_fullscreen) || (!CSettings.bFullScreen && _fullscreen))
|
||||
ToggleFullScreen();
|
||||
|
||||
@@ -469,8 +493,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
if (CTime.IsRunning())
|
||||
delay = (int)Math.Floor(CConfig.CalcCycleTime() - CTime.GetMilliseconds());
|
||||
|
||||
if (delay >= 1)
|
||||
|
||||
if (delay >= 1 && CConfig.VSync == EOffOn.TR_CONFIG_OFF)
|
||||
System.Threading.Thread.Sleep(delay);
|
||||
|
||||
CTime.CalculateFPS();
|
||||
@@ -483,11 +507,13 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
public bool Unload()
|
||||
{
|
||||
while (_Textures.Count > 0)
|
||||
STexture[] textures = new STexture[_Textures.Count];
|
||||
_Textures.Values.CopyTo(textures, 0);
|
||||
for (int i = 0; i < _Textures.Count; i++ )
|
||||
{
|
||||
STexture tex = _Textures[0];
|
||||
RemoveTexture(ref tex);
|
||||
RemoveTexture(ref textures[i]);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -513,7 +539,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
CFonts.Style = text.Style;
|
||||
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
|
||||
}
|
||||
|
||||
#endregion main stuff
|
||||
|
||||
#region Basic Draw Methods
|
||||
public void ClearScreen()
|
||||
{
|
||||
@@ -554,7 +581,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
lock (MutexTexture)
|
||||
{
|
||||
texture.index = _IDs.Dequeue();
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
@@ -637,6 +664,8 @@ namespace Vocaluxe.Lib.Draw
|
||||
#endregion Basic Draw Methods
|
||||
|
||||
#region Textures
|
||||
|
||||
#region adding
|
||||
public STexture AddTexture(string TexturePath)
|
||||
{
|
||||
if (System.IO.File.Exists(TexturePath))
|
||||
@@ -758,7 +787,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
lock (MutexTexture)
|
||||
{
|
||||
texture.index = _IDs.Dequeue();
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
@@ -822,7 +851,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
lock (MutexTexture)
|
||||
{
|
||||
texture.index = _IDs.Dequeue();
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
@@ -887,7 +916,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
lock (MutexTexture)
|
||||
{
|
||||
texture.index = _IDs.Dequeue();
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
@@ -901,18 +930,22 @@ namespace Vocaluxe.Lib.Draw
|
||||
queque.data = Data;
|
||||
queque.height = H;
|
||||
queque.width = W;
|
||||
texture.height = H;
|
||||
texture.width = W;
|
||||
|
||||
lock (MutexTexture)
|
||||
{
|
||||
texture.index = _IDs.Dequeue();
|
||||
queque.ID = texture.index;
|
||||
_Queque.Add(queque);
|
||||
_Textures.Add(texture);
|
||||
_Textures[texture.index] = texture;
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
#endregion adding
|
||||
|
||||
#region updating
|
||||
public bool UpdateTexture(ref STexture Texture, IntPtr Data)
|
||||
{
|
||||
if (_TextureExists(ref Texture))
|
||||
@@ -1020,6 +1053,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#endregion updating
|
||||
|
||||
public void RemoveTexture(ref STexture Texture)
|
||||
{
|
||||
@@ -1027,21 +1061,13 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
lock (MutexTexture)
|
||||
{
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
{
|
||||
if (_Textures[i].index == Texture.index)
|
||||
{
|
||||
_IDs.Enqueue(Texture.index);
|
||||
|
||||
GL.DeleteTexture(Texture.ID);
|
||||
if (Texture.PBO > 0)
|
||||
GL.DeleteBuffers(1, ref Texture.PBO);
|
||||
_Textures.RemoveAt(i);
|
||||
Texture.index = -1;
|
||||
Texture.ID = -1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
_IDs.Enqueue(Texture.index);
|
||||
GL.DeleteTexture(Texture.ID);
|
||||
if (Texture.PBO > 0)
|
||||
GL.DeleteBuffers(1, ref Texture.PBO);
|
||||
_Textures.Remove(Texture.index);
|
||||
Texture.index = -1;
|
||||
Texture.ID = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1050,22 +1076,19 @@ namespace Vocaluxe.Lib.Draw
|
||||
{
|
||||
lock (MutexTexture)
|
||||
{
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
if(_Textures.ContainsKey((Texture.index)))
|
||||
{
|
||||
if (Texture.index == _Textures[i].index)
|
||||
if(_Textures[Texture.index].ID > 0)
|
||||
{
|
||||
if (_Textures[i].ID > 0)
|
||||
{
|
||||
Texture = _Textures[i];
|
||||
return true;
|
||||
}
|
||||
break;
|
||||
Texture = _Textures[Texture.index];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
#region drawing
|
||||
public void DrawTexture(STexture Texture)
|
||||
{
|
||||
DrawTexture(Texture, Texture.rect, Texture.color);
|
||||
@@ -1323,6 +1346,7 @@ namespace Vocaluxe.Lib.Draw
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
}
|
||||
}
|
||||
#endregion drawing
|
||||
|
||||
public int TextureCount()
|
||||
{
|
||||
@@ -1338,15 +1362,9 @@ namespace Vocaluxe.Lib.Draw
|
||||
|
||||
STextureQueque q = _Queque[0];
|
||||
STexture texture = new STexture(-1);
|
||||
int index = -1;
|
||||
for (int i = 0; i < _Textures.Count; i++)
|
||||
if (_Textures.ContainsKey(q.ID))
|
||||
{
|
||||
if (_Textures[i].index == q.ID)
|
||||
{
|
||||
texture = _Textures[i];
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
texture = _Textures[q.ID];
|
||||
}
|
||||
|
||||
if (texture.index < 1)
|
||||
@@ -1386,9 +1404,15 @@ namespace Vocaluxe.Lib.Draw
|
||||
GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, 0, q.width, q.height,
|
||||
OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, q.data);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureParameterName.ClampToEdge);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureParameterName.ClampToEdge);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
|
||||
GL.Ext.GenerateMipmap(GenerateMipmapTarget.Texture2D);
|
||||
|
||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||
|
||||
// Add to Texture List
|
||||
@@ -1396,12 +1420,11 @@ namespace Vocaluxe.Lib.Draw
|
||||
texture.rect = new SRectF(0f, 0f, texture.width, texture.height, 0f);
|
||||
texture.TexturePath = String.Empty;
|
||||
|
||||
_Textures[index] = texture;
|
||||
_Textures[texture.index] = texture;
|
||||
q.data = null;
|
||||
_Queque.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Textures
|
||||
|
||||
#endregion implementation
|
||||
|
||||
@@ -260,12 +260,9 @@ namespace Vocaluxe.Menu
|
||||
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
{
|
||||
if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
|
||||
{
|
||||
CLog.StartBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
|
||||
_Screens[i].LoadTheme();
|
||||
CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
|
||||
}
|
||||
CLog.StartBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
|
||||
Screens[i].LoadTheme();
|
||||
CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
|
||||
}
|
||||
|
||||
for (int i = 0; i < _PopupScreens.Count; i++)
|
||||
@@ -279,10 +276,7 @@ namespace Vocaluxe.Menu
|
||||
ReloadCursor();
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
{
|
||||
if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
|
||||
{
|
||||
_Screens[i].ReloadTheme();
|
||||
}
|
||||
Screens[i].ReloadTheme();
|
||||
}
|
||||
|
||||
for (int i = 0; i < _PopupScreens.Count; i++)
|
||||
@@ -296,10 +290,7 @@ namespace Vocaluxe.Menu
|
||||
ReloadCursor();
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
{
|
||||
if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
|
||||
{
|
||||
_Screens[i].ReloadTextures();
|
||||
}
|
||||
Screens[i].ReloadTextures();
|
||||
}
|
||||
|
||||
for (int i = 0; i < _PopupScreens.Count; i++)
|
||||
@@ -313,10 +304,7 @@ namespace Vocaluxe.Menu
|
||||
CTheme.SaveTheme();
|
||||
for (int i = 0; i < _Screens.Count; i++)
|
||||
{
|
||||
if (Enum.GetNames(typeof(EScreens))[i] != Enum.GetName(typeof(EScreens), (int)EScreens.ScreenCredits))
|
||||
{
|
||||
_Screens[i].SaveTheme();
|
||||
}
|
||||
Screens[i].SaveTheme();
|
||||
}
|
||||
|
||||
for (int i = 0; i < _PopupScreens.Count; i++)
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace Vocaluxe.Screens
|
||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||
const int ScreenVersion = 1;
|
||||
|
||||
|
||||
private CStatic logo;
|
||||
private CParticleEffect starsRed;
|
||||
private CParticleEffect starsBlue;
|
||||
@@ -45,6 +44,18 @@ namespace Vocaluxe.Screens
|
||||
|
||||
private List<string[]> paragraphs;
|
||||
private List<CText> paragraphTexts;
|
||||
|
||||
private STexture _TexLogo;
|
||||
private STexture _TexPerfectNoteStar;
|
||||
|
||||
private STexture _TexNameBrunzel;
|
||||
private STexture _TexNameDarkice;
|
||||
private STexture _TexNameFlokuep;
|
||||
private STexture _TexNameMesand;
|
||||
private STexture _TexNameBohning;
|
||||
private STexture _TexNameBabene03;
|
||||
private STexture _TexNamePantero;
|
||||
private STexture _TexNamePinky007;
|
||||
|
||||
public CScreenCredits()
|
||||
{
|
||||
@@ -96,6 +107,81 @@ namespace Vocaluxe.Screens
|
||||
paragraphs.Add(words);
|
||||
}
|
||||
|
||||
public override void LoadTheme()
|
||||
{
|
||||
//Vocaluxe-Logo
|
||||
CDataBase.GetCreditsRessource("Logo_voc.png", ref _TexLogo);
|
||||
|
||||
//Little stars for logo
|
||||
CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref _TexPerfectNoteStar);
|
||||
|
||||
//brunzel
|
||||
CDataBase.GetCreditsRessource("brunzel.png", ref _TexNameBrunzel);
|
||||
|
||||
//Darkice
|
||||
CDataBase.GetCreditsRessource("Darkice.png", ref _TexNameDarkice);
|
||||
|
||||
//flokuep
|
||||
CDataBase.GetCreditsRessource("flokuep.png", ref _TexNameFlokuep);
|
||||
|
||||
//bohning
|
||||
CDataBase.GetCreditsRessource("bohning.png", ref _TexNameBohning);
|
||||
|
||||
//mesand
|
||||
CDataBase.GetCreditsRessource("mesand.png", ref _TexNameMesand);
|
||||
|
||||
//babene03
|
||||
CDataBase.GetCreditsRessource("babene03.png", ref _TexNameBabene03);
|
||||
|
||||
//pantero
|
||||
CDataBase.GetCreditsRessource("pantero.png", ref _TexNamePantero);
|
||||
|
||||
//Pinky007
|
||||
CDataBase.GetCreditsRessource("Pinky007.png", ref _TexNamePinky007);
|
||||
|
||||
//Prepare Text
|
||||
int lastY = 280;
|
||||
for (int i = 0; i < paragraphs.Count; i++)
|
||||
{
|
||||
string line = "";
|
||||
for (int e = 0; e < paragraphs[i].Length; e++)
|
||||
{
|
||||
if (paragraphs[i][e] != null)
|
||||
{
|
||||
string newline = line + " " + paragraphs[i][e];
|
||||
CText text = new CText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
|
||||
if (CDraw.GetTextBounds(text).Width < (CSettings.iRenderW - 220))
|
||||
{
|
||||
line = line + " " + paragraphs[i][e];
|
||||
|
||||
//Check if all words are used
|
||||
if ((e + 1) == paragraphs[i].Length)
|
||||
{
|
||||
text.Text = line;
|
||||
paragraphTexts.Add(text);
|
||||
line = "";
|
||||
lastY += 40;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
paragraphTexts.Add(text);
|
||||
line = " " + paragraphs[i][e];
|
||||
lastY += 27;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReloadTheme() {}
|
||||
|
||||
public override void SaveTheme() {}
|
||||
|
||||
public override void UnloadTextures() {}
|
||||
|
||||
public override void ReloadTextures() {}
|
||||
|
||||
public override bool HandleInput(KeyEvent KeyEvent)
|
||||
{
|
||||
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode))
|
||||
@@ -150,137 +236,92 @@ namespace Vocaluxe.Screens
|
||||
|
||||
public override void OnShow()
|
||||
{
|
||||
STexture tex = new STexture();
|
||||
STexture particleTex = new STexture();
|
||||
base.OnShow();
|
||||
|
||||
//Vocaluxe-Logo
|
||||
CDataBase.GetCreditsRessource("Logo_voc.png", ref tex);
|
||||
logo = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - tex.width)/2, -270 , tex.width, tex.height, -2));
|
||||
|
||||
logo = new CStatic(_TexLogo, new SColorF(1, 1, 1, 1), new SRectF((CSettings.iRenderW - _TexLogo.width) / 2, -270, _TexLogo.width, _TexLogo.height, -2));
|
||||
|
||||
//Little stars for logo
|
||||
CDataBase.GetCreditsRessource("PerfectNoteStar.png", ref particleTex);
|
||||
int numstars = (int)(logo.Rect.W * 0.25f /2f);
|
||||
starsRed = new CParticleEffect(numstars, new SColorF(1, 0, 0, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), particleTex, 35, EParticeType.Star);
|
||||
starsBlue = new CParticleEffect(numstars, new SColorF(0.149f, 0.415f, 0.819f, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), particleTex, 35, EParticeType.Star);
|
||||
int numstars = (int)(logo.Rect.W * 0.25f / 2f);
|
||||
starsRed = new CParticleEffect(numstars, new SColorF(1, 0, 0, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), _TexPerfectNoteStar, 35, EParticeType.Star);
|
||||
starsBlue = new CParticleEffect(numstars, new SColorF(0.149f, 0.415f, 0.819f, 1), new SRectF(logo.Rect.X, logo.Rect.Y, logo.Rect.W, logo.Rect.H, -1), _TexPerfectNoteStar, 35, EParticeType.Star);
|
||||
|
||||
//Credit names
|
||||
_CreditNames = new List<CCreditName>();
|
||||
|
||||
CCreditName CreditEntry = new CCreditName();
|
||||
|
||||
//brunzel
|
||||
CDataBase.GetCreditsRessource("brunzel.png", ref tex);
|
||||
CCreditName CreditEntryBrunzel = new CCreditName();
|
||||
CreditEntryBrunzel.image = new CStatic(tex, new SColorF(1,1,1,1), new SRectF(-450, 580, 400, 120, -4));
|
||||
CreditEntryBrunzel.image = new CStatic(_TexNameBrunzel, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4));
|
||||
CreditEntryBrunzel.particleRect = new SRectF(CreditEntryBrunzel.image.Rect.X + 342, CreditEntryBrunzel.image.Rect.Y + 4, 30, 30, -5);
|
||||
CreditEntryBrunzel.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryBrunzel.particleRect, particleTex, 35, EParticeType.Star);
|
||||
CreditEntryBrunzel.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryBrunzel.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star);
|
||||
CreditEntryBrunzel.active = true;
|
||||
CreditEntryBrunzel.direction = EDirection.Left;
|
||||
_CreditNames.Add(CreditEntryBrunzel);
|
||||
|
||||
//Darkice
|
||||
CDataBase.GetCreditsRessource("Darkice.png", ref tex);
|
||||
CCreditName CreditEntryDarkice = new CCreditName();
|
||||
CreditEntryDarkice.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 400, 120, -4));
|
||||
CreditEntryDarkice.image = new CStatic(_TexNameDarkice, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 400, 120, -4));
|
||||
CreditEntryDarkice.particleRect = new SRectF(CreditEntryDarkice.image.Rect.X + 242, CreditEntryDarkice.image.Rect.Y + 23, 30, 30, -5);
|
||||
CreditEntryDarkice.particle = new CParticleEffect(8, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryDarkice.particleRect, particleTex, 35, EParticeType.Star);
|
||||
CreditEntryDarkice.particle = new CParticleEffect(8, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryDarkice.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star);
|
||||
CreditEntryDarkice.active = true;
|
||||
CreditEntryDarkice.direction = EDirection.Right;
|
||||
_CreditNames.Add(CreditEntryDarkice);
|
||||
|
||||
//flokuep
|
||||
CDataBase.GetCreditsRessource("flokuep.png", ref tex);
|
||||
CCreditName CreditEntryFlokuep = new CCreditName();
|
||||
CreditEntryFlokuep.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4));
|
||||
CreditEntryFlokuep.particleRect = new SRectF(CreditEntryFlokuep.image.Rect.X + 141, CreditEntryFlokuep.image.Rect.Y-2, 30, 30, -5);
|
||||
CreditEntryFlokuep.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryFlokuep.particleRect, particleTex, 35, EParticeType.Star);
|
||||
CreditEntryFlokuep.image = new CStatic(_TexNameFlokuep, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 400, 120, -4));
|
||||
CreditEntryFlokuep.particleRect = new SRectF(CreditEntryFlokuep.image.Rect.X + 141, CreditEntryFlokuep.image.Rect.Y - 2, 30, 30, -5);
|
||||
CreditEntryFlokuep.particle = new CParticleEffect(8, new SColorF(1, 0, 0, 1), CreditEntryFlokuep.particleRect, _TexPerfectNoteStar, 35, EParticeType.Star);
|
||||
CreditEntryFlokuep.active = true;
|
||||
CreditEntryFlokuep.direction = EDirection.Left;
|
||||
_CreditNames.Add(CreditEntryFlokuep);
|
||||
|
||||
//bohning
|
||||
CDataBase.GetCreditsRessource("bohning.png", ref tex);
|
||||
CCreditName CreditEntryBohning = new CCreditName();
|
||||
CreditEntryBohning.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
|
||||
CreditEntryBohning.image = new CStatic(_TexNameBohning, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
|
||||
CreditEntryBohning.particleRect = new SRectF(CreditEntryBohning.image.Rect.X + 172, CreditEntryBohning.image.Rect.Y + 16, 10, 10, -5);
|
||||
CreditEntryBohning.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryBohning.particleRect, particleTex, 25, EParticeType.Star);
|
||||
CreditEntryBohning.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryBohning.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
|
||||
CreditEntryBohning.active = true;
|
||||
CreditEntryBohning.direction = EDirection.Right;
|
||||
_CreditNames.Add(CreditEntryBohning);
|
||||
|
||||
//mesand
|
||||
CDataBase.GetCreditsRessource("mesand.png", ref tex);
|
||||
CCreditName CreditEntryMesand = new CCreditName();
|
||||
CreditEntryMesand.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
|
||||
CreditEntryMesand.image = new CStatic(_TexNameMesand, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
|
||||
CreditEntryMesand.particleRect = new SRectF(CreditEntryMesand.image.Rect.X + 240, CreditEntryMesand.image.Rect.Y - 2, 10, 10, -5);
|
||||
CreditEntryMesand.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntryMesand.particleRect, particleTex, 25, EParticeType.Star);
|
||||
CreditEntryMesand.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntryMesand.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
|
||||
CreditEntryMesand.active = true;
|
||||
CreditEntryMesand.direction = EDirection.Left;
|
||||
_CreditNames.Add(CreditEntryMesand);
|
||||
|
||||
//babene03
|
||||
CDataBase.GetCreditsRessource("babene03.png", ref tex);
|
||||
CCreditName CreditEntryBabene03 = new CCreditName();
|
||||
CreditEntryBabene03.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
|
||||
CreditEntryBabene03.image = new CStatic(_TexNameBabene03, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
|
||||
CreditEntryBabene03.particleRect = new SRectF(CreditEntryBabene03.image.Rect.X + 7, CreditEntryBabene03.image.Rect.Y + 4, 10, 10, -5);
|
||||
CreditEntryBabene03.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryBabene03.particleRect, particleTex, 25, EParticeType.Star);
|
||||
CreditEntryBabene03.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryBabene03.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
|
||||
CreditEntryBabene03.active = true;
|
||||
CreditEntryBabene03.direction = EDirection.Right;
|
||||
_CreditNames.Add(CreditEntryBabene03);
|
||||
|
||||
//pantero
|
||||
CDataBase.GetCreditsRessource("pantero.png", ref tex);
|
||||
CCreditName CreditEntrypantero = new CCreditName();
|
||||
CreditEntrypantero.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
|
||||
CreditEntrypantero.image = new CStatic(_TexNamePantero, new SColorF(1, 1, 1, 1), new SRectF(-450, 580, 350, 110, -4));
|
||||
CreditEntrypantero.particleRect = new SRectF(CreditEntrypantero.image.Rect.X + 140, CreditEntrypantero.image.Rect.Y + 15, 10, 10, -5);
|
||||
CreditEntrypantero.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntrypantero.particleRect, particleTex, 25, EParticeType.Star);
|
||||
CreditEntrypantero.particle = new CParticleEffect(4, new SColorF(1, 0, 0, 1), CreditEntrypantero.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
|
||||
CreditEntrypantero.active = true;
|
||||
CreditEntrypantero.direction = EDirection.Left;
|
||||
_CreditNames.Add(CreditEntrypantero);
|
||||
|
||||
|
||||
//Pinky007
|
||||
CDataBase.GetCreditsRessource("Pinky007.png", ref tex);
|
||||
CCreditName CreditEntryPinky007 = new CCreditName();
|
||||
CreditEntryPinky007.image = new CStatic(tex, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
|
||||
CreditEntryPinky007.image = new CStatic(_TexNamePinky007, new SColorF(1, 1, 1, 1), new SRectF(CSettings.iRenderW, 580, 350, 110, -4));
|
||||
CreditEntryPinky007.particleRect = new SRectF(CreditEntryPinky007.image.Rect.X + 42, CreditEntryPinky007.image.Rect.Y + 15, 10, 10, -5);
|
||||
CreditEntryPinky007.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f ,0.819f, 1), CreditEntryPinky007.particleRect, particleTex, 25, EParticeType.Star);
|
||||
CreditEntryPinky007.particle = new CParticleEffect(4, new SColorF(0.149f, 0.415f, 0.819f, 1), CreditEntryPinky007.particleRect, _TexPerfectNoteStar, 25, EParticeType.Star);
|
||||
CreditEntryPinky007.active = true;
|
||||
CreditEntryPinky007.direction = EDirection.Right;
|
||||
_CreditNames.Add(CreditEntryPinky007);
|
||||
|
||||
//Prepare Text
|
||||
int lastY = 280;
|
||||
for (int i = 0; i < paragraphs.Count; i++)
|
||||
{
|
||||
string line = "";
|
||||
for (int e = 0; e < paragraphs[i].Length; e++ )
|
||||
{
|
||||
if (paragraphs[i][e] != null)
|
||||
{
|
||||
string newline = line + " " + paragraphs[i][e];
|
||||
CText text = new CText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
|
||||
if (CDraw.GetTextBounds(text).Width < (CSettings.iRenderW - 220))
|
||||
{
|
||||
line = line + " " + paragraphs[i][e];
|
||||
|
||||
//Check if all words are used
|
||||
if ((e + 1) == paragraphs[i].Length)
|
||||
{
|
||||
text.Text = line;
|
||||
paragraphTexts.Add(text);
|
||||
line = "";
|
||||
lastY += 40;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
paragraphTexts.Add(text);
|
||||
line = " "+paragraphs[i][e];
|
||||
lastY += 27;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
TextTimer.Reset();
|
||||
LogoTimer.Reset();
|
||||
CreditsTimer.Reset();
|
||||
|
||||
@@ -186,6 +186,7 @@ namespace Vocaluxe.Screens
|
||||
_Round = 0;
|
||||
_Pos = 0;
|
||||
_Scores = new List<SScores>();
|
||||
_NewEntryIDs.Clear();
|
||||
AddScoresToDB();
|
||||
LoadScores();
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace Vocaluxe.Screens
|
||||
{
|
||||
JumpTo(KeyEvent.Unicode);
|
||||
return true;
|
||||
}*/
|
||||
} */
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -305,11 +305,10 @@ namespace Vocaluxe.Screens
|
||||
id = CSongs.VisibleSongs[song].ID;
|
||||
}
|
||||
|
||||
// here is a fault: SetSelectedSong should point to the visible index
|
||||
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)
|
||||
int visibleID = Array.FindIndex<Vocaluxe.Lib.Song.CSong>(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase));
|
||||
if (visibleID > -1)
|
||||
{
|
||||
id = s.ID;
|
||||
id = visibleID;
|
||||
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(id);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user