diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index c0ece78c..6231e96b 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -212,8 +212,8 @@ Webcams Webcam-Resolution Screen adjustments - Press CTR + ALT + SHIFT + Arrows to adjust screen - CTR + ALT + SHIFT + 0 to reset + Press CTR + ALT (+ SHIFT) + Arrows|"+" to adjust screen + CTR + ALT + 0 to reset Top left Top right Bottom left diff --git a/Output/Languages/German.xml b/Output/Languages/German.xml index 4ded8f3f..751bf476 100644 --- a/Output/Languages/German.xml +++ b/Output/Languages/German.xml @@ -211,8 +211,8 @@ Webcams Webcam-Auflösung Anzeigeanpassungen - STRG + ALT + SHIFT + Pfeiltasten drücken um den Bildschirm anzupassen - STRG + ALT + SHIFT + 0 um die Anpassungen zurückzusetzen + STRG + ALT (+ SHIFT) + Pfeiltasten|"+" drücken um den Bildschirm anzupassen + STRG + ALT + 0 um die Anpassungen zurückzusetzen Oben links Oben rechts Unten links diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index d7aee117..6ef94a42 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -72,6 +72,8 @@ namespace Vocaluxe.Base public static int BorderTop; public static int BorderBottom; + public static EGeneralAlignment ScreenAlignment = EGeneralAlignment.Middle; + public static EAntiAliasingModes AAMode = EAntiAliasingModes.X0; public static EOffOn VSync = EOffOn.TR_CONFIG_ON; @@ -225,6 +227,8 @@ namespace Vocaluxe.Base xmlReader.TryGetIntValue("//root/Graphics/ScreenW", ref ScreenW); xmlReader.TryGetIntValue("//root/Graphics/ScreenH", ref ScreenH); + xmlReader.TryGetEnumValue("//root/Graphics/ScreenAlignment", ref ScreenAlignment); + xmlReader.TryGetIntValue("//root/Graphics/BorderLeft", ref BorderLeft); xmlReader.TryGetIntValue("//root/Graphics/BorderRight", ref BorderRight); xmlReader.TryGetIntValue("//root/Graphics/BorderTop", ref BorderTop); @@ -403,6 +407,8 @@ namespace Vocaluxe.Base writer.WriteElementString("ScreenW", ScreenW.ToString()); writer.WriteElementString("ScreenH", ScreenH.ToString()); + writer.WriteElementString("ScreenAlignment", Enum.GetName(typeof(EGeneralAlignment), ScreenAlignment)); + writer.WriteComment("Screen borders (pixels)"); writer.WriteElementString("BorderLeft", BorderLeft.ToString()); writer.WriteElementString("BorderRight", BorderRight.ToString()); diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 69bf1c51..cc4e3f92 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -353,32 +353,55 @@ namespace Vocaluxe.Base if (!eventsAvailable) keyEvent = inputKeyEvent; - if (keyEvent.IsArrowKey() || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0) + if (keyEvent.IsArrowKey() || keyEvent.Key == Keys.NumPad0 || keyEvent.Key == Keys.D0 || keyEvent.Key == Keys.Add) { _Cursor.Deactivate(); - if (keyEvent.ModAlt && keyEvent.ModCtrl && keyEvent.ModShift) + if (keyEvent.ModAlt && keyEvent.ModCtrl) { switch (keyEvent.Key) { - case Keys.Left: - CConfig.BorderLeft -= 1; - CConfig.BorderRight -= 1; - CConfig.BorderTop -= 1; - CConfig.BorderBottom -= 1; - break; case Keys.Right: - CConfig.BorderLeft += 1; - CConfig.BorderRight += 1; - CConfig.BorderTop += 1; - CConfig.BorderBottom += 1; + if (keyEvent.ModShift) + CConfig.BorderLeft++; + else + CConfig.BorderRight--; + break; + case Keys.Left: + if (keyEvent.ModShift) + CConfig.BorderLeft--; + else + CConfig.BorderRight++; + break; + case Keys.Down: + if (keyEvent.ModShift) + CConfig.BorderTop++; + else + CConfig.BorderBottom--; + break; + case Keys.Up: + if (keyEvent.ModShift) + CConfig.BorderTop--; + else + CConfig.BorderBottom++; break; case Keys.D0: case Keys.NumPad0: - CConfig.BorderLeft = 0; - CConfig.BorderRight = 0; - CConfig.BorderTop = 0; - CConfig.BorderBottom = 0; + CConfig.BorderLeft = CConfig.BorderRight = CConfig.BorderTop = CConfig.BorderBottom = 0; + break; + case Keys.Add: + switch (CConfig.ScreenAlignment) + { + case EGeneralAlignment.Middle: + CConfig.ScreenAlignment = EGeneralAlignment.End; + break; + case EGeneralAlignment.End: + CConfig.ScreenAlignment = EGeneralAlignment.Start; + break; + default: + CConfig.ScreenAlignment = EGeneralAlignment.Middle; + break; + } break; } CConfig.SaveConfig(); diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 84680772..46cc3492 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -52,11 +52,6 @@ namespace Vocaluxe.Lib.Draw private VertexBuffer _VertexBuffer; private IndexBuffer _IndexBuffer; - private int _H = 1; - private int _W = 1; - private int _Y; - private int _X; - private CTexture _BlankTexture; private readonly Queue _Vertices = new Queue(); @@ -186,29 +181,14 @@ namespace Vocaluxe.Lib.Draw if (_Form.ClientSize.Width == 0 || _Form.ClientSize.Height == 0) _Form.ClientSize = _SizeBeforeMinimize; - int newH = _Form.ClientSize.Height; - int newW = _Form.ClientSize.Width; - _Y = 0; - _X = 0; - - if (newW / (float)newH > CSettings.GetRenderAspect()) - { - //The windows width is too big - newW = (int)Math.Round(newH * CSettings.GetRenderAspect()); - _X = (_Form.ClientSize.Width - newW) / 2; - } - else - { - //The windows height is too big - newH = (int)Math.Round(newW / CSettings.GetRenderAspect()); - _Y = (_Form.ClientSize.Height - newH) / 2; - } - - if (_H == newH && _W == newW) + if (_H == _Form.ClientSize.Height && _W == _Form.ClientSize.Width && CConfig.ScreenAlignment == _CurrentAlignment) return; - _H = newH; - _W = newW; + _CurrentAlignment = CConfig.ScreenAlignment; + _H = _Form.ClientSize.Height; + _W = _Form.ClientSize.Width; + + _AdjustAspect(false); //Apply the new sizes to the PresentParameters _PresentParameters.BackBufferWidth = _Form.ClientSize.Width; @@ -220,7 +200,6 @@ namespace Vocaluxe.Lib.Draw _Reset(); //All configurations got flushed due to Reset(), so apply them again _InitDevice(); - //Set the new Viewport _Device.Viewport = new Viewport(_X, _Y, _W, _H); } @@ -376,10 +355,12 @@ namespace Vocaluxe.Lib.Draw protected override void _AdjustNewBorders() { - Matrix translate = Matrix.Translation(new Vector3(-(float)CSettings.RenderW / 2, (float)CSettings.RenderH / 2, 0)); + const float dx = (float)CSettings.RenderW / 2; + const float dy = (float)CSettings.RenderH / 2; + Matrix translate = Matrix.Translation(new Vector3(-dx, dy, 0)); Matrix projection = Matrix.OrthoOffCenterLH( - -(float)CSettings.RenderW / 2 - _BorderLeft, (float)CSettings.RenderW / 2 + _BorderRight, - -(float)CSettings.RenderH / 2 - _BorderBottom, (float)CSettings.RenderH / 2 + _BorderTop, + -dx - _BorderLeft, dx + _BorderRight, + -dy - _BorderBottom, dy + _BorderTop, CSettings.ZNear, CSettings.ZFar); if (_Device.SetTransform(TransformState.Projection, projection).IsFailure) diff --git a/Vocaluxe/Lib/Draw/CDrawBase.cs b/Vocaluxe/Lib/Draw/CDrawBase.cs index 19512ce3..a068eb4c 100644 --- a/Vocaluxe/Lib/Draw/CDrawBase.cs +++ b/Vocaluxe/Lib/Draw/CDrawBase.cs @@ -41,10 +41,16 @@ namespace Vocaluxe.Lib.Draw protected readonly Dictionary _Textures = new Dictionary(); private readonly Queue _TexturesToLoad = new Queue(); + protected int _H; + protected int _W; + protected int _Y; + protected int _X; + protected int _BorderLeft; protected int _BorderRight; protected int _BorderTop; protected int _BorderBottom; + protected EGeneralAlignment _CurrentAlignment = EGeneralAlignment.Middle; public abstract void ClearScreen(); protected abstract void _AdjustNewBorders(); @@ -72,6 +78,48 @@ namespace Vocaluxe.Lib.Draw } } + protected void _AdjustAspect(bool reverse) + { + if (_W / (float)_H > CSettings.GetRenderAspect()) + { + //The windows width is too big + int old = _W; + _W = (int)Math.Round(_H * CSettings.GetRenderAspect()); + int diff = old - _W; + switch (_CurrentAlignment) + { + case EGeneralAlignment.Start: + _X = 0; + break; + case EGeneralAlignment.Middle: + _X = diff / 2; + break; + case EGeneralAlignment.End: + _X = diff; + break; + } + } + else + { + //The windows height is too big + int old = _H; + _H = (int)Math.Round(_W / CSettings.GetRenderAspect()); + int diff = old - _H; + switch (_CurrentAlignment) + { + case EGeneralAlignment.Start: + _Y = reverse ? diff : 0; + break; + case EGeneralAlignment.Middle: + _Y = diff / 2; + break; + case EGeneralAlignment.End: + _Y = reverse ? 0 : diff; + break; + } + } + } + /// /// Calculates the next power of two if the device has the POW2 flag set /// @@ -404,6 +452,9 @@ namespace Vocaluxe.Lib.Draw _AdjustNewBorders(); } + if (_CurrentAlignment != CConfig.ScreenAlignment) + _DoResize(); + if (CConfig.VSync == EOffOn.TR_CONFIG_OFF) { if (CTime.IsRunning()) diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index ecbf7194..06449aa9 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -88,18 +88,12 @@ namespace Vocaluxe.Lib.Draw { #region private vars private readonly GLControl _Control; - - private int _H = 1; - private int _W = 1; - private int _Y; - private int _X; - private bool _UsePBO; #endregion private vars public COpenGL() { - _Form = new CFormHook {ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH)}; + _Form = new CFormHook(); //Check AA Mode CConfig.AAMode = (EAntiAliasingModes)_CheckAntiAliasingMode((int)CConfig.AAMode); @@ -214,25 +208,10 @@ namespace Vocaluxe.Lib.Draw { _H = _Control.Height; _W = _Control.Width; - _Y = 0; - _X = 0; + _CurrentAlignment = CConfig.ScreenAlignment; - if (_W / (float)_H > CSettings.GetRenderAspect()) - { - //The windows width is too big - _W = (int)Math.Round(_H * CSettings.GetRenderAspect()); - _X = (_Control.Width - _W) / 2; - } - else - { - //The windows height is too big - _H = (int)Math.Round(_W / CSettings.GetRenderAspect()); - _Y = (_Control.Height - _H) / 2; - } - - GL.MatrixMode(MatrixMode.Projection); - GL.LoadIdentity(); - GL.Ortho(0, CSettings.RenderW, CSettings.RenderH, 0, CSettings.ZNear, CSettings.ZFar); + _AdjustAspect(true); + _AdjustNewBorders(); GL.Viewport(_X, _Y, _W, _H); } @@ -244,6 +223,9 @@ namespace Vocaluxe.Lib.Draw if (!base.Init()) return false; + //OpenGL needs that here but D3D needs it in the constructor, so do NOT unify! + _Form.ClientSize = new Size(CConfig.ScreenW, CConfig.ScreenH); + // Init Texturing GL.Enable(EnableCap.Texture2D); @@ -288,7 +270,9 @@ namespace Vocaluxe.Lib.Draw protected override void _AdjustNewBorders() { - //TODO: Implement!!! + GL.MatrixMode(MatrixMode.Projection); + GL.LoadIdentity(); + GL.Ortho(-CConfig.BorderLeft, CConfig.BorderRight + CSettings.RenderW, CConfig.BorderBottom + CSettings.RenderH, -CConfig.BorderTop, CSettings.ZNear, CSettings.ZFar); } public CTexture CopyScreen() diff --git a/VocaluxeLib/Enums.cs b/VocaluxeLib/Enums.cs index 4db6424c..f7bcfd44 100644 --- a/VocaluxeLib/Enums.cs +++ b/VocaluxeLib/Enums.cs @@ -46,6 +46,13 @@ namespace VocaluxeLib Stretch } + public enum EGeneralAlignment + { + Middle, + Start, + End + } + public enum EAlignment { Left,