From 19f81943d6772673a5b08dfd0687a851157c0f93 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Fri, 26 Sep 2014 15:05:19 +0200 Subject: [PATCH] Introduce RenderRect for easy access to the full screen rect --- Vocaluxe/Base/CMain.cs | 9 +++- Vocaluxe/Base/CSettings.cs | 1 + Vocaluxe/Base/CVideoPlayer.cs | 3 +- Vocaluxe/Screens/CScreenCredits.cs | 4 +- Vocaluxe/Screens/CScreenSing.cs | 5 +- VocaluxeLib/CHelper.cs | 2 +- VocaluxeLib/IBasic.cs | 3 +- VocaluxeLib/Menu/CBackground.cs | 19 +++---- VocaluxeLib/Menu/CMenu.cs | 49 +++++++------------ VocaluxeLib/Menu/CObjectInteractions.cs | 2 +- .../Menu/SongMenu/CSongMenuTileBoard.cs | 7 ++- 11 files changed, 48 insertions(+), 56 deletions(-) diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 3da3360c..7831ec19 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -174,6 +174,11 @@ namespace Vocaluxe.Base return CSettings.RenderH; } + public SRectF GetRenderRect() + { + return CSettings.RenderRect; + } + public bool IsTabNavigation() { return CSettings.TabNavigation; @@ -438,9 +443,9 @@ namespace Vocaluxe.Base CDraw.DrawTexture(textureRef, bounds, aspect, color); } - public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float reflectionSpace, float reflectionHeight) + public void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight) { - CDraw.DrawTextureReflection(texture, rect, color, reflectionSpace, reflectionHeight); + CDraw.DrawTextureReflection(texture, rect, color, bounds, reflectionSpace, reflectionHeight); } public CTextureRef AddTexture(string fileName) diff --git a/Vocaluxe/Base/CSettings.cs b/Vocaluxe/Base/CSettings.cs index b419e7b1..36a66d15 100644 --- a/Vocaluxe/Base/CSettings.cs +++ b/Vocaluxe/Base/CSettings.cs @@ -65,6 +65,7 @@ namespace Vocaluxe.Base public const int RenderW = 1280; public const int RenderH = 720; + public static readonly SRectF RenderRect = new SRectF(0, 0, RenderW, RenderH, 0); public const int ZNear = -100; public const int ZFar = 100; diff --git a/Vocaluxe/Base/CVideoPlayer.cs b/Vocaluxe/Base/CVideoPlayer.cs index 0838ae7c..cfa7f6e7 100644 --- a/Vocaluxe/Base/CVideoPlayer.cs +++ b/Vocaluxe/Base/CVideoPlayer.cs @@ -1,5 +1,4 @@ using System.Diagnostics; -using System.Drawing; using VocaluxeLib; using VocaluxeLib.Draw; @@ -63,7 +62,7 @@ namespace Vocaluxe.Base if (_VideoTexture == null) return; - CDraw.DrawTexture(_VideoTexture, new SRectF(0, 0, CSettings.RenderW, CSettings.RenderH, CSettings.ZFar / 4), EAspect.Crop); + CDraw.DrawTexture(_VideoTexture, CSettings.RenderRect, EAspect.Crop); } public void PreLoad() diff --git a/Vocaluxe/Screens/CScreenCredits.cs b/Vocaluxe/Screens/CScreenCredits.cs index dc9904fc..4404bebc 100644 --- a/Vocaluxe/Screens/CScreenCredits.cs +++ b/Vocaluxe/Screens/CScreenCredits.cs @@ -142,6 +142,8 @@ namespace Vocaluxe.Screens private CTextureRef _TexNamePantero; private CTextureRef _TexNamePinky007; + private static SColorF _BGColor = new SColorF(0, 0.18f, 0.474f, 1); + public override void Init() { base.Init(); @@ -360,7 +362,7 @@ namespace Vocaluxe.Screens base.Draw(); //Draw background - CDraw.DrawRect(new SColorF(0, 0.18f, 0.474f, 1), new SRectF(0, 0, CSettings.RenderW, CSettings.RenderH, 0)); + CDraw.DrawRect(_BGColor, CSettings.RenderRect); //Draw stars _StarsBlue.Draw(); diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 2a7da149..e3f1f525 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -478,8 +478,9 @@ namespace Vocaluxe.Screens background = _Background; if (background != null) { - var bounds = new SRectF(0, 0, CSettings.RenderW, CSettings.RenderH, 0); - CDraw.DrawTexture(background, bounds, aspect, background.Color); + SRectF bounds = CSettings.RenderRect; + SRectF rect = CHelper.FitInBounds(bounds, background.OrigAspect, aspect); + CDraw.DrawTexture(background, rect, background.Color, bounds); } else if (_SlideShow != null) _SlideShow.Draw(); diff --git a/VocaluxeLib/CHelper.cs b/VocaluxeLib/CHelper.cs index d54a2d00..6c143b59 100644 --- a/VocaluxeLib/CHelper.cs +++ b/VocaluxeLib/CHelper.cs @@ -84,7 +84,7 @@ namespace VocaluxeLib /// Bounds to fit the rect in /// The original aspectRatio of the rect/image/... /// - /// Crop: Fit fully in bounds cutting off overhanging parts (same on both sides)
+ /// Crop: No empty space in bounds but has overhanging parts (same on both sides)
/// LetterBox: Fit the long side possibly leaving some space on the other (rect will be centered)
/// StretcH: Just fit the rect in the bounds (rect=bounds) /// diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index e4b3b4cf..81734aa2 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -70,6 +70,7 @@ namespace VocaluxeLib { int GetRenderW(); int GetRenderH(); + SRectF GetRenderRect(); bool IsTabNavigation(); float GetZFar(); @@ -147,7 +148,7 @@ namespace VocaluxeLib void DrawTexture(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, bool mirrored = false); void DrawTexture(CTextureRef textureRef, SRectF bounds, EAspect aspect); void DrawTexture(CTextureRef textureRef, SRectF bounds, EAspect aspect, SColorF color); - void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, float reflectionSpace, float reflectionHeight); + void DrawTextureReflection(CTextureRef texture, SRectF rect, SColorF color, SRectF bounds, float reflectionSpace, float reflectionHeight); CTextureRef AddTexture(string fileName); void RemoveTexture(ref CTextureRef texture); diff --git a/VocaluxeLib/Menu/CBackground.cs b/VocaluxeLib/Menu/CBackground.cs index 9faeb4c9..33cd979c 100644 --- a/VocaluxeLib/Menu/CBackground.cs +++ b/VocaluxeLib/Menu/CBackground.cs @@ -36,16 +36,11 @@ namespace VocaluxeLib.Menu [XmlType("Background")] public struct SThemeBackground { - [XmlAttributeAttribute(AttributeName = "Name")] - public string Name; - [XmlElement("Type")] - public EBackgroundTypes Type; - [XmlArray] - public List SlideShowTextures; - [XmlElement("Video")] - public string VideoName; - [XmlElement("Skin")] - public string TextureName; + [XmlAttribute(AttributeName = "Name")] public string Name; + [XmlElement("Type")] public EBackgroundTypes Type; + [XmlArray] public List SlideShowTextures; + [XmlElement("Video")] public string VideoName; + [XmlElement("Skin")] public string TextureName; public SThemeColor Color; } @@ -225,7 +220,9 @@ namespace VocaluxeLib.Menu #region internal private static SRectF _GetDrawRect() { - return new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), CBase.Settings.GetZFar() / 4); + SRectF rect = CBase.Settings.GetRenderRect(); + rect.Z = CBase.Settings.GetZFar() / 4; + return rect; } private void _DrawColor() diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 2a69aed7..fe6189df 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -33,37 +33,24 @@ namespace VocaluxeLib.Menu public string ScreenName; public int ScreenVersion; } + [XmlType("Screen")] public struct STheme { - [XmlElement("Informations")] - public SScreenInformation ScreenInformation; - [XmlArray("Backgrounds")] - public List Backgrounds; - [XmlArray("Statics")] - public List Statics; - [XmlArray("Texts")] - public List Texts; - [XmlArray("Buttons")] - public List Buttons; - [XmlArray("SongMenus")] - public List SongMenus; - [XmlArray("Lyrics")] - public List Lyrics; - [XmlArray("SelectSlides")] - public List SelectSlides; - [XmlArray("SingNotes")] - public List SingNotes; - [XmlArray("NameSelections")] - public List NameSelections; - [XmlArray("Equalizers")] - public List Equalizers; - [XmlArray("Playlists")] - public List Playlists; - [XmlArray("ParticleEffects")] - public List ParticleEffects; - [XmlArray("ScreenSettings")] - public List ScreenSettings; + [XmlElement("Informations")] public SScreenInformation ScreenInformation; + [XmlArray("Backgrounds")] public List Backgrounds; + [XmlArray("Statics")] public List Statics; + [XmlArray("Texts")] public List Texts; + [XmlArray("Buttons")] public List Buttons; + [XmlArray("SongMenus")] public List SongMenus; + [XmlArray("Lyrics")] public List Lyrics; + [XmlArray("SelectSlides")] public List SelectSlides; + [XmlArray("SingNotes")] public List SingNotes; + [XmlArray("NameSelections")] public List NameSelections; + [XmlArray("Equalizers")] public List Equalizers; + [XmlArray("Playlists")] public List Playlists; + [XmlArray("ParticleEffects")] public List ParticleEffects; + [XmlArray("ScreenSettings")] public List ScreenSettings; } struct SZSort @@ -157,7 +144,7 @@ namespace VocaluxeLib.Menu _MouseDY = 0; _Active = false; - _ScreenArea = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), 0f); + _ScreenArea = CBase.Settings.GetRenderRect(); _ThemeBackgrounds = null; _ThemeStatics = null; @@ -249,7 +236,7 @@ namespace VocaluxeLib.Menu foreach (SThemeParticleEffect pe in Theme.ParticleEffects) _AddParticleEffect(new CParticleEffect(pe, _PartyModeID), pe.Name); - foreach(SThemePlaylist pl in Theme.Playlists) + foreach (SThemePlaylist pl in Theme.Playlists) _AddPlaylist(new CPlaylist(pl, _PartyModeID), pl.Name); foreach (SScreenSetting ss in Theme.ScreenSettings) @@ -268,7 +255,7 @@ namespace VocaluxeLib.Menu _AddStatic(new CStatic(st, _PartyModeID), st.Name); foreach (SThemeText te in Theme.Texts) - _AddText(new CText(te, _PartyModeID), te.Name); + _AddText(new CText(te, _PartyModeID), te.Name); } catch (InvalidOperationException e) { diff --git a/VocaluxeLib/Menu/CObjectInteractions.cs b/VocaluxeLib/Menu/CObjectInteractions.cs index 791412d8..c2c99823 100644 --- a/VocaluxeLib/Menu/CObjectInteractions.cs +++ b/VocaluxeLib/Menu/CObjectInteractions.cs @@ -69,7 +69,7 @@ namespace VocaluxeLib.Menu _MouseDY = 0; Active = false; - _ScreenArea = new SRectF(0f, 0f, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), 0f); + _ScreenArea = CBase.Settings.GetRenderRect(); } public void Clear() diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 14504d80..6a3b1248 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -199,7 +199,7 @@ namespace VocaluxeLib.Menu.SongMenu _Tiles.Add(tile); } } - _ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), Rect.Z); + _ScrollRect = CBase.Settings.GetRenderRect(); } public override void Update(SScreenSongOptions songOptions) @@ -500,9 +500,8 @@ namespace VocaluxeLib.Menu.SongMenu if (vidtex.Color.A < 1) _CoverBig.Draw(EAspect.Crop); SRectF rect = CHelper.FitInBounds(_CoverBig.Rect, vidtex.OrigAspect, EAspect.Crop); - - CBase.Drawing.DrawTexture(vidtex, rect); - CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); + CBase.Drawing.DrawTexture(vidtex, rect, vidtex.Color, _CoverBig.Rect); + CBase.Drawing.DrawTextureReflection(vidtex, rect, vidtex.Color, _CoverBig.Rect, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); } else _CoverBig.Draw(EAspect.Crop);