From ef111fde2f7f85238e25c6cadbeb9d6f169a1ee0 Mon Sep 17 00:00:00 2001 From: mephasor Date: Thu, 16 Oct 2014 13:57:34 -0300 Subject: [PATCH 01/21] Added a list style song menu which can be activated in the game menu screen --- PitchTracker/PitchTracker.vcxproj | 10 +- Vocaluxe/Base/CConfig.cs | 3 +- VocaluxeLib/Enums.cs | 1 + VocaluxeLib/Menu/SongMenu/CSongMenu.cs | 4 +- .../Menu/SongMenu/CSongMenuListAndCover.cs | 660 ++++++++++++++++++ VocaluxeLib/VocaluxeLib.csproj | 1 + 6 files changed, 672 insertions(+), 7 deletions(-) create mode 100644 VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs diff --git a/PitchTracker/PitchTracker.vcxproj b/PitchTracker/PitchTracker.vcxproj index 06c0b94c..2435c698 100644 --- a/PitchTracker/PitchTracker.vcxproj +++ b/PitchTracker/PitchTracker.vcxproj @@ -1,5 +1,5 @@  - + Debug @@ -28,26 +28,26 @@ DynamicLibrary true - v110_xp + v120_xp Unicode DynamicLibrary true - v110_xp + v120_xp Unicode DynamicLibrary false - v110_xp + v120_xp true Unicode DynamicLibrary false - v110_xp + v120_xp true Unicode diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 5b42d5aa..84bb941f 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -125,7 +125,8 @@ namespace Vocaluxe.Base }; // Game - public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD; + //public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD; + public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_LIST__AND_COVER; public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST; public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON; public static float ScoreAnimationTime = 10; diff --git a/VocaluxeLib/Enums.cs b/VocaluxeLib/Enums.cs index 4db6424c..7d5cb78e 100644 --- a/VocaluxeLib/Enums.cs +++ b/VocaluxeLib/Enums.cs @@ -172,6 +172,7 @@ namespace VocaluxeLib //TR_CONFIG_LIST, //a simple list //TR_CONFIG_DREIDEL, //as in ultrastar deluxe TR_CONFIG_TILE_BOARD, //chessboard like + TR_CONFIG_LIST__AND_COVER // list of covers and artist - title //TR_CONFIG_BOOK //for playlists // ReSharper restore InconsistentNaming } diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs index 74bac712..1964e6ac 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs @@ -199,7 +199,9 @@ namespace VocaluxeLib.Menu.SongMenu case ESongMenu.TR_CONFIG_TILE_BOARD: _SongMenu = new CSongMenuTileBoard(_PartyModeID); break; - + case ESongMenu.TR_CONFIG_LIST__AND_COVER: + _SongMenu = new CSongMenuListAndCover(_PartyModeID); + break; //case ESongMenu.TR_CONFIG_BOOK: // _SongMenu = new CSongMenuBook(); // break; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs new file mode 100644 index 00000000..e21f51e9 --- /dev/null +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs @@ -0,0 +1,660 @@ +#region license +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +#endregion + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Windows.Forms; +using VocaluxeLib.Draw; +using VocaluxeLib.PartyModes; +using VocaluxeLib.Songs; + +namespace VocaluxeLib.Menu.SongMenu +{ + class CSongMenuListAndCover : CSongMenuFramework + { + private SRectF _ScrollRect; + private List _Tiles; + private List _Texts; + private CStatic _CoverBig; + private CStatic _TextBG; + private CStatic _DuetIcon; + private CStatic _VideoIcon; + private CStatic _MedleyCalcIcon; + private CStatic _MedleyTagIcon; + + private CTexture _CoverBigBGTexture; + private CTexture _CoverBGTexture; + + private CText _Artist; + private CText _Title; + private CText _SongLength; + + //private int _NumW; + //private int _NumH; + + private float _SpaceW; + private float _SpaceH; + + private int _TileW; + private int _TileH; + + //TODO: remove all 1* from the code (artifacts from translation from tile board) + //TODO: make variable list length + private int _ListLength = 15; + private float _CoverTileWidth; + private float _ListTextWidth; + + + // Offset is the song or categoryNr of the tile in the left upper corner + private int _Offset; + + private float _Length = -1f; + private int _LastKnownElements; + private int _LastKnownCategory; + + private bool _MouseWasInRect; + + public override float SelectedTileZoomFactor + { + get { return 1.2f; } + } + + protected override int _SelectionNr + { + set + { + int max = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); + base._SelectionNr = value.Clamp(-1, max - 1, true); + //Update list in case we scrolled + _UpdateList(); + + _UpdateTileSelection(); + } + } + + private void _UpdateTileSelection() + { + foreach (CStatic tile in _Tiles) + tile.Selected = false; + + int tileNr = _SelectionNr - _Offset; + if (tileNr >= 0 && tileNr < _Tiles.Count) + _Tiles[tileNr].Selected = true; + } + + public override bool SmallView + { + set + { + if (SmallView == value) + return; + base.SmallView = value; + _InitTiles(); + _UpdateList(true); + _UpdateTileSelection(); + } + } + + public CSongMenuListAndCover(int partyModeID) + : base(partyModeID) {} + + protected override int _PreviewNr + { + set + { + if (value == base._PreviewNr) + { + if (!CBase.BackgroundMusic.IsPlaying() && value != -1) + CBase.BackgroundMusic.PlayPreview(); + return; + } + base._PreviewNr = value; + _UpdatePreview(); + } + } + + public override void Init() + { + base.Init(); + + _SpaceW = _Theme.SongMenuTileBoard.SpaceW; + _SpaceH = _Theme.SongMenuTileBoard.SpaceH; + + _CoverBig = _Theme.SongMenuTileBoard.StaticCoverBig; + _TextBG = _Theme.SongMenuTileBoard.StaticTextBG; + _DuetIcon = _Theme.SongMenuTileBoard.StaticDuetIcon; + _VideoIcon = _Theme.SongMenuTileBoard.StaticVideoIcon; + _MedleyCalcIcon = _Theme.SongMenuTileBoard.StaticMedleyCalcIcon; + _MedleyTagIcon = _Theme.SongMenuTileBoard.StaticMedleyTagIcon; + + _Artist = _Theme.SongMenuTileBoard.TextArtist; + _Title = _Theme.SongMenuTileBoard.TextTitle; + _SongLength = _Theme.SongMenuTileBoard.TextSongLength; + + _PreviewNr = -1; + _InitTiles(); + } + + private void _InitTiles() + { + Rect = _Theme.SongMenuTileBoard.TileRect; + + //keep tile ratio 3/2 so the covers still look nice. + _CoverTileWidth = _ListLength * 3 / 2; + _ListTextWidth = Rect.W - _ListTextWidth; + + _TileW = (int)((Rect.W - _SpaceW * (_CoverTileWidth - 1)) / _CoverTileWidth); + _TileH = (int)((Rect.H - _SpaceH * (_ListLength - 1)) / _ListLength); + + _CoverBGTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID); + _CoverBigBGTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID); + + //Create cover tiles + _Tiles = new List(); + _Texts = new List(); + + + + for (int i = 0; i < _ListLength; i++) + { + //Create Cover + var rect = new SRectF(Rect.X + (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _TileW, _TileH, Rect.Z); + var tile = new CStatic(_PartyModeID, _CoverBGTexture, _Color, rect); + _Tiles.Add(tile); + + //Create text + var textRect = new SRectF(Rect.X + 2*(_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _ListTextWidth, _TileH, Rect.Z); + //string textString = _Artist.Text + " - " + _Title.Text; + string textString = ""; + CText text = new CText(textRect.X,textRect.Y,textRect.Z, + textRect.H,textRect.W,EAlignment.Left,EStyle.Normal, + "Normal",_Artist.Color,textString); + + _Texts.Add(text); + } + + _ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), Rect.Z); + } + + public override void Update(SScreenSongOptions songOptions) + { + base.Update(songOptions); + + if (songOptions.Selection.RandomOnly) + _PreviewNr = _SelectionNr; + + if (_Length < 0 && CBase.Songs.IsInCategory() && CBase.BackgroundMusic.GetLength() > 0) + _UpdateLength(CBase.Songs.GetVisibleSong(_PreviewNr)); + } + + private void _UpdatePreview() + { + //First hide everything so we just have to set what we actually want + _CoverBig.Texture = _CoverBigBGTexture; + _Artist.Text = String.Empty; + _Title.Text = String.Empty; + _SongLength.Text = String.Empty; + _DuetIcon.Visible = false; + _VideoIcon.Visible = false; + _MedleyCalcIcon.Visible = false; + _MedleyTagIcon.Visible = false; + _Length = -1f; + + //Check if nothing is selected (for preview) + if (_PreviewNr < 0) + return; + + if (CBase.Songs.IsInCategory()) + { + CSong song = CBase.Songs.GetVisibleSong(_PreviewNr); + //Check if we have a valid song (song still visible, index >=0 etc is checked by framework) + if (song == null) + { + //Display at least the category + CCategory category = CBase.Songs.GetCategory(CBase.Songs.GetCurrentCategoryIndex()); + //Check if we have a valid category + if (category == null) + return; + _CoverBig.Texture = category.CoverTextureBig; + _Artist.Text = category.Name; + return; + } + _CoverBig.Texture = song.CoverTextureBig; + _Artist.Text = song.Artist; + _Title.Text = song.Title; + _DuetIcon.Visible = song.IsDuet; + _VideoIcon.Visible = song.VideoFileName != ""; + _MedleyCalcIcon.Visible = song.Medley.Source == EDataSource.Calculated; + _MedleyTagIcon.Visible = song.Medley.Source == EDataSource.Tag; + + _UpdateLength(song); + } + else + { + CCategory category = CBase.Songs.GetCategory(_PreviewNr); + //Check if we have a valid category + if (category == null) + return; + _CoverBig.Texture = category.CoverTextureBig; + _Artist.Text = category.Name; + + int num = category.GetNumSongsNotSung(); + String songOrSongs = (num == 1) ? "TR_SCREENSONG_NUMSONG" : "TR_SCREENSONG_NUMSONGS"; + _Title.Text = CBase.Language.Translate(songOrSongs).Replace("%v", num.ToString()); + } + } + + private void _UpdateLength(CSong song) + { + if (song == null) + return; + float time = CBase.BackgroundMusic.GetLength(); + if (Math.Abs(song.Finish) > 0.001) + time = song.Finish; + + // The audiobackend is ready to return the length + if (time > 0) + { + time -= song.Start; + var min = (int)Math.Floor(time / 60f); + var sec = (int)(time - min * 60f); + _SongLength.Text = min.ToString("00") + ":" + sec.ToString("00"); + _Length = time; + } + else + _SongLength.Text = "..."; + } + + public override void OnShow() + { + _LastKnownElements = -1; //Force refresh of list + if (!CBase.Songs.IsInCategory()) + { + if ((CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && CBase.Songs.GetNumCategories() > 0) || CBase.Songs.GetNumCategories() == 1) + _EnterCategory(0); + } + if (CBase.Songs.IsInCategory()) + SetSelectedSong(_SelectionNr < 0 ? 0 : _SelectionNr); + else + SetSelectedCategory(_SelectionNr < 0 ? 0 : _SelectionNr); + _PreviewNr = _SelectionNr; + _UpdateListIfRequired(); + } + + public override bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options) + { + if (keyEvent.KeyPressed) + return false; + + bool moveAllowed = !options.Selection.RandomOnly || (options.Selection.CategoryChangeAllowed && !CBase.Songs.IsInCategory()); + bool catChangePossible = CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && options.Selection.CategoryChangeAllowed; + + //If nothing selected set a reasonable default value + if (keyEvent.IsArrowKey() && moveAllowed && _SelectionNr < 0) + _SelectionNr = (_PreviewNr < 0) ? _Offset : _PreviewNr; + + switch (keyEvent.Key) + { + case Keys.Enter: + if (CBase.Songs.IsInCategory()) + { + if (_SelectionNr >= 0 && _PreviewNr != _SelectionNr) + { + _PreviewNr = _SelectionNr; + keyEvent.Handled = true; + } + } + else + { + _EnterCategory(_PreviewNr); + keyEvent.Handled = true; + } + break; + + case Keys.Escape: + case Keys.Back: + if (CBase.Songs.IsInCategory() && catChangePossible) + { + _LeaveCategory(); + keyEvent.Handled = true; + } + break; + + case Keys.PageUp: + if (catChangePossible) + { + _PrevCategory(); + keyEvent.Handled = true; + } + break; + + case Keys.PageDown: + if (catChangePossible) + { + _NextCategory(); + keyEvent.Handled = true; + } + break; + + case Keys.Left: + //Check for >0 so we do not allow selection of nothing (-1) + if (_SelectionNr > 0 && moveAllowed) + { + _SelectionNr--; + keyEvent.Handled = true; + } + break; + + case Keys.Right: + if (moveAllowed) + { + _SelectionNr++; + keyEvent.Handled = true; + } + break; + + case Keys.Up: + if (keyEvent.ModShift) + { + if (catChangePossible) + { + _PrevCategory(); + keyEvent.Handled = true; + } + } + else if (_SelectionNr >= 1 && moveAllowed) + { + _SelectionNr -= 1; + keyEvent.Handled = true; + } + break; + + case Keys.Down: + if (keyEvent.ModShift) + { + if (catChangePossible) + { + _NextCategory(); + keyEvent.Handled = true; + } + } + else if (moveAllowed) + { + _SelectionNr += 1; + keyEvent.Handled = true; + } + break; + } + if (!CBase.Songs.IsInCategory()) + _PreviewNr = _SelectionNr; + return keyEvent.Handled; + } + + public override bool HandleMouse(ref SMouseEvent mouseEvent, SScreenSongOptions songOptions) + { + if (!songOptions.Selection.RandomOnly || (!CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed)) + { + if (mouseEvent.Wheel != 0 && CHelper.IsInBounds(_ScrollRect, mouseEvent)) + _UpdateList(_Offset + 1 * mouseEvent.Wheel); + + int lastSelection = _SelectionNr; + int i = 0; + bool somethingSelected = false; + + //needed for hover over list selection + SRectF songRect; + + + foreach (CStatic tile in _Tiles) + { + //create a rect including the cover and text of the song. + //(this way mouse over text should make a selection as well) + songRect = new SRectF(tile.Rect.X, tile.Rect.Y, Rect.W, tile.Rect.H, tile.Rect.Z); + if (tile.Texture != _CoverBGTexture && CHelper.IsInBounds(songRect, mouseEvent)) + { + somethingSelected = true; + _SelectionNr = i + _Offset; + if (!CBase.Songs.IsInCategory()) + _PreviewNr = i + _Offset; + break; + } + i++; + } + //Reset selection only if we moved out of the rect to avoid loosing it when selecting random songs + if (_MouseWasInRect && !somethingSelected) + _SelectionNr = -1; + if (mouseEvent.Sender == ESender.WiiMote && _SelectionNr != lastSelection && _SelectionNr != -1) + CBase.Controller.SetRumble(0.050f); + } + _MouseWasInRect = CHelper.IsInBounds(Rect, mouseEvent); + + if (mouseEvent.RB) + { + if (CBase.Songs.IsInCategory() && CBase.Songs.GetNumCategories() > 0 && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && + songOptions.Selection.CategoryChangeAllowed) + { + _LeaveCategory(); + return true; + } + if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode) + { + CBase.Graphics.FadeTo(EScreens.ScreenMain); + return true; + } + } + else if (mouseEvent.LB) + { + if (_SelectionNr >= 0 && _MouseWasInRect) + { + if (CBase.Songs.IsInCategory()) + { + if (_PreviewNr == _SelectionNr) + return false; + _PreviewNr = _SelectionNr; + } + else + EnterSelectedCategory(); + return true; + } + } + return false; + } + + public override void Draw() + { + foreach (CStatic tile in _Tiles) + { + if (tile.Selected && Active) + tile.Draw(EAspect.Crop, SelectedTileZoomFactor, -0.1f); + else + { + EAspect aspect = (tile.Texture != _CoverBGTexture) ? EAspect.Crop : EAspect.Stretch; + tile.Draw(aspect); + } + } + + //hightlight the text of the selected song + int i = 0; + foreach(CText text in _Texts) + { + if(i < _Tiles.Count && _Tiles.ElementAt(i).Selected && Active) + { + text.Style = EStyle.BoldItalic; + } + else if (i < _Tiles.Count) + { + text.Style = EStyle.Normal; + } else + { + text.Text = ""; + } + text.Draw(); + i++; + } + + _TextBG.Draw(); + + CTexture vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null; + + if (vidtex != null) + { + if (vidtex.Color.A < 1) + _CoverBig.Draw(EAspect.Crop); + var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); + RectangleF rect; + CHelper.SetRect(bounds, out rect, vidtex.OrigAspect, EAspect.Crop); + var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); + var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f); + + CBase.Drawing.DrawTexture(vidtex, vidRect, vidtex.Color, vidRectBounds); + CBase.Drawing.DrawTextureReflection(vidtex, vidRect, vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); + } + else + _CoverBig.Draw(EAspect.Crop); + + + _Artist.Draw(); + _Title.Draw(); + _SongLength.Draw(); + _DuetIcon.Draw(); + _VideoIcon.Draw(); + _MedleyCalcIcon.Draw(); + _MedleyTagIcon.Draw(); + } + + public override CStatic GetSelectedSongCover() + { + return _Tiles.FirstOrDefault(tile => tile.Selected); + } + + protected override void _EnterCategory(int categoryNr) + { + base._EnterCategory(categoryNr); + + SetSelectedSong(0); + _UpdateListIfRequired(); + } + + protected override void _LeaveCategory() + { + base._LeaveCategory(); + + SetSelectedCategory(0); + _UpdateListIfRequired(); + } + + private void _NextCategory() + { + if (CBase.Songs.IsInCategory()) + { + CBase.Songs.NextCategory(); + _EnterCategory(CBase.Songs.GetCurrentCategoryIndex()); + } + } + + private void _PrevCategory() + { + if (CBase.Songs.IsInCategory()) + { + CBase.Songs.PrevCategory(); + _EnterCategory(CBase.Songs.GetCurrentCategoryIndex()); + } + } + + private void _UpdateListIfRequired() + { + int curElements = CBase.Songs.IsInCategory() ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); + if ((_LastKnownElements == curElements) && (_LastKnownCategory == CBase.Songs.GetCurrentCategoryIndex())) + return; + + _LastKnownCategory = CBase.Songs.GetCurrentCategoryIndex(); + _LastKnownElements = curElements; + CBase.Songs.UpdateRandomSongList(); + _UpdateList(true); + } + + private int _GetOffsetForPosition(int index, int rowNum = 0) + { + return (index / 1) * 1 - (1 * rowNum.Clamp(0, _ListLength - 1, true)); + } + + private void _UpdateList(bool force = false) + { + int offset; + if (_SelectionNr < _Offset && _SelectionNr >= 0) + offset = _GetOffsetForPosition(_SelectionNr); + else if (_SelectionNr >= _Offset + 1 * _ListLength) + offset = _GetOffsetForPosition(_SelectionNr, _ListLength); + else + offset = _Offset; + _UpdateList(offset, force); + } + + private void _UpdateList(int offset, bool force = false) + { + bool isInCategory = CBase.Songs.IsInCategory(); + int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); + + offset = offset.Clamp(0, _GetOffsetForPosition(itemCount, _ListLength - 1), true); + + if (offset == _Offset && !force) + return; + + CSong currentSong; + string textString; + + for (int i = 0; i < _Tiles.Count; i++) + { + if (itemCount > i + offset) + { + currentSong = CBase.Songs.GetVisibleSong(i+offset); + //isInCategory does not really seem to be interesting.. :D + _Tiles[i].Texture = isInCategory ? currentSong.CoverTextureSmall : currentSong.CoverTextureSmall; + _Tiles[i].Color = new SColorF(1f, 1f, 1f, 1f); + + textString = currentSong.Artist + " - "+ currentSong.Title; + _Texts.ElementAt(i).Text = textString; + } + else + { + _Tiles[i].Texture = _CoverBGTexture; + _Tiles[i].Color = _Color; + _Texts.ElementAt(i).Text = ""; + } + } + _Offset = offset; + } + + public override void LoadTextures() + { + base.LoadTextures(); + + _Theme.SongMenuTileBoard.StaticCoverBig.ReloadTextures(); + _Theme.SongMenuTileBoard.StaticTextBG.ReloadTextures(); + _Theme.SongMenuTileBoard.StaticDuetIcon.ReloadTextures(); + _Theme.SongMenuTileBoard.StaticVideoIcon.ReloadTextures(); + _Theme.SongMenuTileBoard.StaticMedleyCalcIcon.ReloadTextures(); + _Theme.SongMenuTileBoard.StaticMedleyTagIcon.ReloadTextures(); + + _Theme.SongMenuTileBoard.TextArtist.ReloadTextures(); + _Theme.SongMenuTileBoard.TextTitle.ReloadTextures(); + _Theme.SongMenuTileBoard.TextSongLength.ReloadTextures(); + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index a367e8e1..3614ddf8 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -105,6 +105,7 @@ + From 7c5d5786a6d81b4419eb89df32918801c78b239f Mon Sep 17 00:00:00 2001 From: mephasor Date: Thu, 16 Oct 2014 14:52:32 -0300 Subject: [PATCH 02/21] Added German and English Language entries for the list view. --- Output/Languages/English.xml | 1 + Output/Languages/German.xml | 1 + VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs | 2 -- 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Output/Languages/English.xml b/Output/Languages/English.xml index 6554f2dc..cd7cccae 100644 --- a/Output/Languages/English.xml +++ b/Output/Languages/English.xml @@ -49,6 +49,7 @@ List Dreidel TileBoard + Song List Book On Demand At Startup diff --git a/Output/Languages/German.xml b/Output/Languages/German.xml index 50ffef0a..36078c2b 100644 --- a/Output/Languages/German.xml +++ b/Output/Languages/German.xml @@ -49,6 +49,7 @@ Liste Dreidel TileBoard + Songliste Book Bei Bedarf Bei Programmstart diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs index e21f51e9..38e5fc80 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs @@ -45,8 +45,6 @@ namespace VocaluxeLib.Menu.SongMenu private CText _Title; private CText _SongLength; - //private int _NumW; - //private int _NumH; private float _SpaceW; private float _SpaceH; From 17a280149236692a7b19f38ee9cb758681e4d066 Mon Sep 17 00:00:00 2001 From: mephasor Date: Thu, 16 Oct 2014 15:17:20 -0300 Subject: [PATCH 03/21] Changed the xml definition of list view to use the already existing one. --- VocaluxeLib/Enums.cs | 4 ++-- VocaluxeLib/Menu/SongMenu/CSongMenu.cs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/VocaluxeLib/Enums.cs b/VocaluxeLib/Enums.cs index 7d5cb78e..3c13e5cc 100644 --- a/VocaluxeLib/Enums.cs +++ b/VocaluxeLib/Enums.cs @@ -169,10 +169,10 @@ namespace VocaluxeLib public enum ESongMenu { // ReSharper disable InconsistentNaming - //TR_CONFIG_LIST, //a simple list + TR_CONFIG_LIST, //a simple list //TR_CONFIG_DREIDEL, //as in ultrastar deluxe TR_CONFIG_TILE_BOARD, //chessboard like - TR_CONFIG_LIST__AND_COVER // list of covers and artist - title + //TR_CONFIG_LIST__AND_COVER // list of covers and artist - title //TR_CONFIG_BOOK //for playlists // ReSharper restore InconsistentNaming } diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs index 1964e6ac..a98a6d78 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs @@ -199,7 +199,7 @@ namespace VocaluxeLib.Menu.SongMenu case ESongMenu.TR_CONFIG_TILE_BOARD: _SongMenu = new CSongMenuTileBoard(_PartyModeID); break; - case ESongMenu.TR_CONFIG_LIST__AND_COVER: + case ESongMenu.TR_CONFIG_LIST: _SongMenu = new CSongMenuListAndCover(_PartyModeID); break; //case ESongMenu.TR_CONFIG_BOOK: From 9e5e48226537f8fdb0a415b25fcecbcf5226d772 Mon Sep 17 00:00:00 2001 From: mephasor Date: Thu, 16 Oct 2014 15:18:39 -0300 Subject: [PATCH 04/21] Changed the list view enum entry to use the already existing one. --- Vocaluxe/Base/CConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 84bb941f..98662afe 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -126,7 +126,7 @@ namespace Vocaluxe.Base // Game //public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD; - public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_LIST__AND_COVER; + public static ESongMenu SongMenu = ESongMenu.TR_CONFIG_TILE_BOARD; public static ESongSorting SongSorting = ESongSorting.TR_CONFIG_ARTIST; public static EOffOn IgnoreArticles = EOffOn.TR_CONFIG_ON; public static float ScoreAnimationTime = 10; From 8e0f4b60d6c3cd0ebc4b523246a4566dc55aec40 Mon Sep 17 00:00:00 2001 From: mephasor Date: Fri, 17 Oct 2014 13:53:11 -0300 Subject: [PATCH 05/21] Changed the SongLoader to handle UTF-8 Strings properly. --- VocaluxeLib/Songs/CSongLoader.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index cd4cf834..9494a2a1 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -140,6 +140,8 @@ namespace VocaluxeLib.Songs continue; } string value = line.Substring(pos + 1).Trim(); + byte[] bytes = Encoding.Default.GetBytes(value); + value = Encoding.UTF8.GetString(bytes); if (value == "") { From 20fce6958588ebf8d9846666d5e8a5caec6fadf6 Mon Sep 17 00:00:00 2001 From: mephasor Date: Sat, 6 Dec 2014 12:40:22 -0400 Subject: [PATCH 06/21] Revert "Changed the SongLoader to handle UTF-8 Strings properly." This reverts commit 8e0f4b60d6c3cd0ebc4b523246a4566dc55aec40. --- VocaluxeLib/Songs/CSongLoader.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index 9494a2a1..cd4cf834 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -140,8 +140,6 @@ namespace VocaluxeLib.Songs continue; } string value = line.Substring(pos + 1).Trim(); - byte[] bytes = Encoding.Default.GetBytes(value); - value = Encoding.UTF8.GetString(bytes); if (value == "") { From 54a14d6395dce0ef659bc7a9b4128cf8cde343aa Mon Sep 17 00:00:00 2001 From: mephasor Date: Sat, 6 Dec 2014 12:40:25 -0400 Subject: [PATCH 07/21] Revert "Revert "Changed the SongLoader to handle UTF-8 Strings properly."" This reverts commit 20fce6958588ebf8d9846666d5e8a5caec6fadf6. --- VocaluxeLib/Songs/CSongLoader.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index cd4cf834..9494a2a1 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -140,6 +140,8 @@ namespace VocaluxeLib.Songs continue; } string value = line.Substring(pos + 1).Trim(); + byte[] bytes = Encoding.Default.GetBytes(value); + value = Encoding.UTF8.GetString(bytes); if (value == "") { From b4414cf08f547b35153ce4e4b660b7822708e963 Mon Sep 17 00:00:00 2001 From: mephasor Date: Sat, 6 Dec 2014 12:40:32 -0400 Subject: [PATCH 08/21] Revert "Revert "Revert "Changed the SongLoader to handle UTF-8 Strings properly.""" This reverts commit 54a14d6395dce0ef659bc7a9b4128cf8cde343aa. --- VocaluxeLib/Songs/CSongLoader.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/VocaluxeLib/Songs/CSongLoader.cs b/VocaluxeLib/Songs/CSongLoader.cs index 9494a2a1..cd4cf834 100644 --- a/VocaluxeLib/Songs/CSongLoader.cs +++ b/VocaluxeLib/Songs/CSongLoader.cs @@ -140,8 +140,6 @@ namespace VocaluxeLib.Songs continue; } string value = line.Substring(pos + 1).Trim(); - byte[] bytes = Encoding.Default.GetBytes(value); - value = Encoding.UTF8.GetString(bytes); if (value == "") { From 0cabd425ef0287fd97eea569f5c4ee31df35db0c Mon Sep 17 00:00:00 2001 From: Flamefire Date: Tue, 9 Dec 2014 22:26:10 +0100 Subject: [PATCH 09/21] Adapt changes in Vocaluxe to SongMenuList --- VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs | 5 +- ...ngMenuListAndCover.cs => CSongMenuList.cs} | 225 +++++++++--------- .../Menu/SongMenu/CSongMenuTileBoard.cs | 18 +- VocaluxeLib/VocaluxeLib.csproj | 2 +- 4 files changed, 121 insertions(+), 129 deletions(-) rename VocaluxeLib/Menu/SongMenu/{CSongMenuListAndCover.cs => CSongMenuList.cs} (76%) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs index e512721d..a74d4913 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs @@ -25,9 +25,8 @@ namespace VocaluxeLib.Menu.SongMenu { switch (CBase.Config.GetSongMenuType()) { - //case ESongMenu.TR_CONFIG_LIST: - // _SongMenu = new CSongMenuList(); - // break; + case ESongMenu.TR_CONFIG_LIST: + return new CSongMenuList(theme, partyModeID); //case ESongMenu.TR_CONFIG_DREIDEL: // _SongMenu = new CSongMenuDreidel(); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs similarity index 76% rename from VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs rename to VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 38e5fc80..cd5f6eb0 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuListAndCover.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -17,7 +17,6 @@ using System; using System.Collections.Generic; -using System.Drawing; using System.Linq; using System.Windows.Forms; using VocaluxeLib.Draw; @@ -26,38 +25,36 @@ using VocaluxeLib.Songs; namespace VocaluxeLib.Menu.SongMenu { - class CSongMenuListAndCover : CSongMenuFramework + class CSongMenuList : CSongMenuFramework { private SRectF _ScrollRect; private List _Tiles; private List _Texts; - private CStatic _CoverBig; - private CStatic _TextBG; - private CStatic _DuetIcon; - private CStatic _VideoIcon; - private CStatic _MedleyCalcIcon; - private CStatic _MedleyTagIcon; + private readonly CStatic _CoverBig; + private readonly CStatic _TextBG; + private readonly CStatic _DuetIcon; + private readonly CStatic _VideoIcon; + private readonly CStatic _MedleyCalcIcon; + private readonly CStatic _MedleyTagIcon; - private CTexture _CoverBigBGTexture; - private CTexture _CoverBGTexture; - - private CText _Artist; - private CText _Title; - private CText _SongLength; + private CTextureRef _CoverBigBGTexture; + private CTextureRef _CoverBGTexture; + private readonly CText _Artist; + private readonly CText _Title; + private readonly CText _SongLength; private float _SpaceW; private float _SpaceH; private int _TileW; private int _TileH; - + //TODO: remove all 1* from the code (artifacts from translation from tile board) //TODO: make variable list length private int _ListLength = 15; private float _CoverTileWidth; private float _ListTextWidth; - // Offset is the song or categoryNr of the tile in the left upper corner private int _Offset; @@ -68,6 +65,8 @@ namespace VocaluxeLib.Menu.SongMenu private bool _MouseWasInRect; + private readonly List _SubElements = new List(); + public override float SelectedTileZoomFactor { get { return 1.2f; } @@ -86,16 +85,6 @@ namespace VocaluxeLib.Menu.SongMenu } } - private void _UpdateTileSelection() - { - foreach (CStatic tile in _Tiles) - tile.Selected = false; - - int tileNr = _SelectionNr - _Offset; - if (tileNr >= 0 && tileNr < _Tiles.Count) - _Tiles[tileNr].Selected = true; - } - public override bool SmallView { set @@ -109,9 +98,6 @@ namespace VocaluxeLib.Menu.SongMenu } } - public CSongMenuListAndCover(int partyModeID) - : base(partyModeID) {} - protected override int _PreviewNr { set @@ -127,48 +113,67 @@ namespace VocaluxeLib.Menu.SongMenu } } + public CSongMenuList(SThemeSongMenu theme, int partyModeID) : base(theme, partyModeID) + { + _SpaceW = _Theme.SongMenuTileBoard.SpaceW; + _SpaceH = _Theme.SongMenuTileBoard.SpaceH; + _Artist = new CText(_Theme.SongMenuTileBoard.TextArtist, _PartyModeID); + _Title = new CText(_Theme.SongMenuTileBoard.TextTitle, _PartyModeID); + _SongLength = new CText(_Theme.SongMenuTileBoard.TextSongLength, _PartyModeID); + _CoverBig = new CStatic(_Theme.SongMenuTileBoard.StaticCoverBig, _PartyModeID); + _TextBG = new CStatic(_Theme.SongMenuTileBoard.StaticTextBG, _PartyModeID); + _DuetIcon = new CStatic(_Theme.SongMenuTileBoard.StaticDuetIcon, _PartyModeID); + _VideoIcon = new CStatic(_Theme.SongMenuTileBoard.StaticVideoIcon, _PartyModeID); + _MedleyCalcIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyCalcIcon, _PartyModeID); + _MedleyTagIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyTagIcon, _PartyModeID); + _SubElements.AddRange(new IMenuElement[] {_Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon}); + } + + private void _ReadSubTheme() + { + _Theme.SongMenuTileBoard.TextArtist = (SThemeText)_Artist.GetTheme(); + _Theme.SongMenuTileBoard.TextSongLength = (SThemeText)_SongLength.GetTheme(); + _Theme.SongMenuTileBoard.TextTitle = (SThemeText)_Title.GetTheme(); + _Theme.SongMenuTileBoard.StaticCoverBig = (SThemeStatic)_CoverBig.GetTheme(); + _Theme.SongMenuTileBoard.StaticDuetIcon = (SThemeStatic)_DuetIcon.GetTheme(); + _Theme.SongMenuTileBoard.StaticMedleyCalcIcon = (SThemeStatic)_MedleyCalcIcon.GetTheme(); + _Theme.SongMenuTileBoard.StaticMedleyTagIcon = (SThemeStatic)_MedleyTagIcon.GetTheme(); + _Theme.SongMenuTileBoard.StaticTextBG = (SThemeStatic)_TextBG.GetTheme(); + _Theme.SongMenuTileBoard.StaticVideoIcon = (SThemeStatic)_VideoIcon.GetTheme(); + } + + public override object GetTheme() + { + _ReadSubTheme(); + return base.GetTheme(); + } + public override void Init() { base.Init(); - _SpaceW = _Theme.SongMenuTileBoard.SpaceW; - _SpaceH = _Theme.SongMenuTileBoard.SpaceH; - - _CoverBig = _Theme.SongMenuTileBoard.StaticCoverBig; - _TextBG = _Theme.SongMenuTileBoard.StaticTextBG; - _DuetIcon = _Theme.SongMenuTileBoard.StaticDuetIcon; - _VideoIcon = _Theme.SongMenuTileBoard.StaticVideoIcon; - _MedleyCalcIcon = _Theme.SongMenuTileBoard.StaticMedleyCalcIcon; - _MedleyTagIcon = _Theme.SongMenuTileBoard.StaticMedleyTagIcon; - - _Artist = _Theme.SongMenuTileBoard.TextArtist; - _Title = _Theme.SongMenuTileBoard.TextTitle; - _SongLength = _Theme.SongMenuTileBoard.TextSongLength; - _PreviewNr = -1; _InitTiles(); } private void _InitTiles() { - Rect = _Theme.SongMenuTileBoard.TileRect; + MaxRect = _Theme.SongMenuTileBoard.TileRect; //keep tile ratio 3/2 so the covers still look nice. - _CoverTileWidth = _ListLength * 3 / 2; + _CoverTileWidth = _ListLength * 3.0f / 2; _ListTextWidth = Rect.W - _ListTextWidth; _TileW = (int)((Rect.W - _SpaceW * (_CoverTileWidth - 1)) / _CoverTileWidth); _TileH = (int)((Rect.H - _SpaceH * (_ListLength - 1)) / _ListLength); - _CoverBGTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBackgroundName, _PartyModeID); - _CoverBigBGTexture = CBase.Theme.GetSkinTexture(_Theme.CoverBigBackgroundName, _PartyModeID); + _CoverBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBackground, _PartyModeID); + _CoverBigBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBigBackground, _PartyModeID); //Create cover tiles _Tiles = new List(); _Texts = new List(); - - for (int i = 0; i < _ListLength; i++) { //Create Cover @@ -177,23 +182,30 @@ namespace VocaluxeLib.Menu.SongMenu _Tiles.Add(tile); //Create text - var textRect = new SRectF(Rect.X + 2*(_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _ListTextWidth, _TileH, Rect.Z); - //string textString = _Artist.Text + " - " + _Title.Text; - string textString = ""; - CText text = new CText(textRect.X,textRect.Y,textRect.Z, - textRect.H,textRect.W,EAlignment.Left,EStyle.Normal, - "Normal",_Artist.Color,textString); + var textRect = new SRectF(Rect.X + 2 * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _ListTextWidth, _TileH, Rect.Z); + //string textString = _Artist.Text + " - " + _Title.Text; + CText text = new CText(textRect.X, textRect.Y, textRect.Z, + textRect.H, textRect.W, EAlignment.Left, EStyle.Normal, + "Normal", _Artist.Color, ""); _Texts.Add(text); } - _ScrollRect = new SRectF(0, 0, CBase.Settings.GetRenderW(), CBase.Settings.GetRenderH(), Rect.Z); + _ScrollRect = CBase.Settings.GetRenderRect(); + } + + private void _UpdateTileSelection() + { + foreach (CStatic tile in _Tiles) + tile.Selected = false; + + int tileNr = _SelectionNr - _Offset; + if (tileNr >= 0 && tileNr < _Tiles.Count) + _Tiles[tileNr].Selected = true; } public override void Update(SScreenSongOptions songOptions) { - base.Update(songOptions); - if (songOptions.Selection.RandomOnly) _PreviewNr = _SelectionNr; @@ -415,15 +427,11 @@ namespace VocaluxeLib.Menu.SongMenu int i = 0; bool somethingSelected = false; - //needed for hover over list selection - SRectF songRect; - - foreach (CStatic tile in _Tiles) { //create a rect including the cover and text of the song. //(this way mouse over text should make a selection as well) - songRect = new SRectF(tile.Rect.X, tile.Rect.Y, Rect.W, tile.Rect.H, tile.Rect.Z); + SRectF songRect = new SRectF(tile.Rect.X, tile.Rect.Y, Rect.W, tile.Rect.H, tile.Rect.Z); if (tile.Texture != _CoverBGTexture && CHelper.IsInBounds(songRect, mouseEvent)) { somethingSelected = true; @@ -452,7 +460,7 @@ namespace VocaluxeLib.Menu.SongMenu } if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode) { - CBase.Graphics.FadeTo(EScreens.ScreenMain); + CBase.Graphics.FadeTo(EScreen.Main); return true; } } @@ -478,7 +486,7 @@ namespace VocaluxeLib.Menu.SongMenu { foreach (CStatic tile in _Tiles) { - if (tile.Selected && Active) + if (tile.Selected) tile.Draw(EAspect.Crop, SelectedTileZoomFactor, -0.1f); else { @@ -487,53 +495,37 @@ namespace VocaluxeLib.Menu.SongMenu } } - //hightlight the text of the selected song + //highlight the text of the selected song int i = 0; - foreach(CText text in _Texts) + foreach (CText text in _Texts) { - if(i < _Tiles.Count && _Tiles.ElementAt(i).Selected && Active) - { - text.Style = EStyle.BoldItalic; - } + if (i < _Tiles.Count && _Tiles[i].Selected) + text.Font.Style = EStyle.BoldItalic; else if (i < _Tiles.Count) - { - text.Style = EStyle.Normal; - } else - { + text.Font.Style = EStyle.Normal; + else text.Text = ""; - } text.Draw(); i++; } _TextBG.Draw(); - CTexture vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null; + CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null; if (vidtex != null) { if (vidtex.Color.A < 1) _CoverBig.Draw(EAspect.Crop); - var bounds = new RectangleF(_CoverBig.Rect.X, _CoverBig.Rect.Y, _CoverBig.Rect.W, _CoverBig.Rect.H); - RectangleF rect; - CHelper.SetRect(bounds, out rect, vidtex.OrigAspect, EAspect.Crop); - var vidRect = new SRectF(rect.X, rect.Y, rect.Width, rect.Height, _CoverBig.Rect.Z); - var vidRectBounds = new SRectF(bounds.X, bounds.Y, bounds.Width, bounds.Height, 0f); - - CBase.Drawing.DrawTexture(vidtex, vidRect, vidtex.Color, vidRectBounds); - CBase.Drawing.DrawTextureReflection(vidtex, vidRect, vidtex.Color, vidRectBounds, _CoverBig.ReflectionSpace, _CoverBig.ReflectionHeight); + SRectF rect = CHelper.FitInBounds(_CoverBig.Rect, vidtex.OrigAspect, EAspect.Crop); + 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); - - _Artist.Draw(); - _Title.Draw(); - _SongLength.Draw(); - _DuetIcon.Draw(); - _VideoIcon.Draw(); - _MedleyCalcIcon.Draw(); - _MedleyTagIcon.Draw(); + foreach (IMenuElement element in _SubElements) + element.Draw(); } public override CStatic GetSelectedSongCover() @@ -614,45 +606,46 @@ namespace VocaluxeLib.Menu.SongMenu if (offset == _Offset && !force) return; - CSong currentSong; - string textString; - for (int i = 0; i < _Tiles.Count; i++) { - if (itemCount > i + offset) + if (i + offset < itemCount) { - currentSong = CBase.Songs.GetVisibleSong(i+offset); - //isInCategory does not really seem to be interesting.. :D - _Tiles[i].Texture = isInCategory ? currentSong.CoverTextureSmall : currentSong.CoverTextureSmall; _Tiles[i].Color = new SColorF(1f, 1f, 1f, 1f); - - textString = currentSong.Artist + " - "+ currentSong.Title; - _Texts.ElementAt(i).Text = textString; + if (isInCategory) + { + CSong currentSong = CBase.Songs.GetVisibleSong(i + offset); + _Tiles[i].Texture = currentSong.CoverTextureSmall; + _Texts[i].Text = currentSong.Artist + " - " + currentSong.Title; + } + else + { + CCategory currentCat = CBase.Songs.GetCategory(i + offset); + _Tiles[i].Texture = currentCat.CoverTextureSmall; + int num = currentCat.GetNumSongsNotSung(); + String songOrSongs = (num == 1) ? "TR_SCREENSONG_NUMSONG" : "TR_SCREENSONG_NUMSONGS"; + _Texts[i].Text = currentCat.Name + " " + CBase.Language.Translate(songOrSongs).Replace("%v", num.ToString()); + } } else { _Tiles[i].Texture = _CoverBGTexture; _Tiles[i].Color = _Color; - _Texts.ElementAt(i).Text = ""; + _Texts[i].Text = ""; } } _Offset = offset; } - public override void LoadTextures() + public override void LoadSkin() { - base.LoadTextures(); + base.LoadSkin(); + foreach (IThemeable themeable in _SubElements.OfType()) + themeable.LoadSkin(); + // Those are drawn seperately so they are not in the above list + _CoverBig.LoadSkin(); + _TextBG.LoadSkin(); - _Theme.SongMenuTileBoard.StaticCoverBig.ReloadTextures(); - _Theme.SongMenuTileBoard.StaticTextBG.ReloadTextures(); - _Theme.SongMenuTileBoard.StaticDuetIcon.ReloadTextures(); - _Theme.SongMenuTileBoard.StaticVideoIcon.ReloadTextures(); - _Theme.SongMenuTileBoard.StaticMedleyCalcIcon.ReloadTextures(); - _Theme.SongMenuTileBoard.StaticMedleyTagIcon.ReloadTextures(); - - _Theme.SongMenuTileBoard.TextArtist.ReloadTextures(); - _Theme.SongMenuTileBoard.TextTitle.ReloadTextures(); - _Theme.SongMenuTileBoard.TextSongLength.ReloadTextures(); + Init(); } } } \ No newline at end of file diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 99469947..1157f97f 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -30,19 +30,19 @@ namespace VocaluxeLib.Menu.SongMenu { private SRectF _ScrollRect; private List _Tiles; - private CStatic _CoverBig; - private CStatic _TextBG; - private CStatic _DuetIcon; - private CStatic _VideoIcon; - private CStatic _MedleyCalcIcon; - private CStatic _MedleyTagIcon; + private readonly CStatic _CoverBig; + private readonly CStatic _TextBG; + private readonly CStatic _DuetIcon; + private readonly CStatic _VideoIcon; + private readonly CStatic _MedleyCalcIcon; + private readonly CStatic _MedleyTagIcon; private CTextureRef _CoverBigBGTexture; private CTextureRef _CoverBGTexture; - private CText _Artist; - private CText _Title; - private CText _SongLength; + private readonly CText _Artist; + private readonly CText _Title; + private readonly CText _SongLength; private int _NumW; private int _NumH; diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index ffa780d3..3eb458fa 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -117,7 +117,7 @@ - + From 84694ccbe0c5c455ecf55530d031109ecd662c68 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 10 Dec 2014 21:11:59 +0100 Subject: [PATCH 10/21] Allow ingame changing of songmenu --- Vocaluxe/Base/CConfig.cs | 16 ++ Vocaluxe/Base/CMain.cs | 7 +- Vocaluxe/Screens/CScreenOptionsGame.cs | 4 +- VocaluxeLib/IBasic.cs | 2 + VocaluxeLib/Menu/CMenu.cs | 11 +- VocaluxeLib/Menu/SongMenu/CSongMenu.cs | 238 ++++++++++++++++++ VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs | 70 ------ VocaluxeLib/VocaluxeLib.csproj | 2 +- 8 files changed, 267 insertions(+), 83 deletions(-) create mode 100644 VocaluxeLib/Menu/SongMenu/CSongMenu.cs delete mode 100644 VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs diff --git a/Vocaluxe/Base/CConfig.cs b/Vocaluxe/Base/CConfig.cs index 2c8cbd51..267b73c4 100644 --- a/Vocaluxe/Base/CConfig.cs +++ b/Vocaluxe/Base/CConfig.cs @@ -126,7 +126,9 @@ namespace Vocaluxe.Base { [DefaultValue(CSettings.FallbackLanguage)] public string Language; public string[] SongFolder; + // ReSharper disable MemberHidesStaticFromOuterClass [DefaultValue(ESongMenu.TR_CONFIG_TILE_BOARD)] public ESongMenu SongMenu; + // ReSharper restore MemberHidesStaticFromOuterClass [DefaultValue(ESongSorting.TR_CONFIG_ARTIST)] public ESongSorting SongSorting; [DefaultValue(EOffOn.TR_CONFIG_ON)] public EOffOn IgnoreArticles; [DefaultValue(10)] public float ScoreAnimationTime; @@ -181,6 +183,7 @@ namespace Vocaluxe.Base public static SConfig Config; public static bool LoadOldThemeFiles; + public static event OnSongMenuChanged SongMenuChanged; //Folders public static readonly List SongFolders = new List @@ -273,6 +276,19 @@ namespace Vocaluxe.Base } } + public static ESongMenu SongMenu + { + get { return Config.Game.SongMenu; } + set + { + if (Config.Game.SongMenu == value) + return; + Config.Game.SongMenu = value; + if (SongMenuChanged != null) + SongMenuChanged(); + } + } + public static void Init() { if (_Initialized) diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 320b8697..58f140bc 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -88,7 +88,7 @@ namespace Vocaluxe.Base public ESongMenu GetSongMenuType() { - return CConfig.Config.Game.SongMenu; + return CConfig.SongMenu; } public EOffOn GetVideosToBackground() @@ -155,6 +155,11 @@ namespace Vocaluxe.Base { return CConfig.LoadOldThemeFiles; } + + public void AddSongMenuListener(OnSongMenuChanged onSongMenuChanged) + { + CConfig.SongMenuChanged += onSongMenuChanged; + } } class CBsettings : ISettings diff --git a/Vocaluxe/Screens/CScreenOptionsGame.cs b/Vocaluxe/Screens/CScreenOptionsGame.cs index ce71f532..40729730 100644 --- a/Vocaluxe/Screens/CScreenOptionsGame.cs +++ b/Vocaluxe/Screens/CScreenOptionsGame.cs @@ -56,7 +56,7 @@ namespace Vocaluxe.Screens _SelectSlides[_SelectSlideLanguage].Selection = CLanguage.LanguageId; _SelectSlides[_SelectSlideDebugLevel].SetValues((int)CConfig.Config.Debug.DebugLevel); - _SelectSlides[_SelectSlideSongMenu].SetValues((int)CConfig.Config.Game.SongMenu); + _SelectSlides[_SelectSlideSongMenu].SetValues((int)CConfig.SongMenu); _SelectSlides[_SelectSlideSongSorting].SetValues((int)CConfig.Config.Game.SongSorting); _SelectSlides[_SelectSlideTabs].SetValues((int)CConfig.Config.Game.Tabs); _SelectSlides[_SelectSlideTimerMode].SetValues((int)CConfig.Config.Game.TimerMode); @@ -136,7 +136,7 @@ namespace Vocaluxe.Screens CLanguage.LanguageId = _SelectSlides[_SelectSlideLanguage].Selection; CConfig.Config.Game.Language = _SelectSlides[_SelectSlideLanguage].Value; CConfig.Config.Debug.DebugLevel = (EDebugLevel)_SelectSlides[_SelectSlideDebugLevel].Selection; - CConfig.Config.Game.SongMenu = (ESongMenu)_SelectSlides[_SelectSlideSongMenu].Selection; + CConfig.SongMenu = (ESongMenu)_SelectSlides[_SelectSlideSongMenu].Selection; CConfig.Config.Game.SongSorting = (ESongSorting)_SelectSlides[_SelectSlideSongSorting].Selection; CConfig.Config.Game.Tabs = (EOffOn)_SelectSlides[_SelectSlideTabs].Selection; CConfig.Config.Game.TimerMode = (ETimerMode)_SelectSlides[_SelectSlideTimerMode].Selection; diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 5262668b..c3f1fbc1 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -27,6 +27,7 @@ using VocaluxeLib.Songs; namespace VocaluxeLib { + public delegate void OnSongMenuChanged(); public interface IConfig { EOffOn GetSaveModifiedSongs(); @@ -58,6 +59,7 @@ namespace VocaluxeLib int GetMaxNumMics(); bool GetLoadOldThemeFiles(); + void AddSongMenuListener(OnSongMenuChanged onSongMenuChanged); } public interface ISettings diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index dfc66cce..4c100a12 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -201,7 +201,7 @@ namespace VocaluxeLib.Menu _AddSingNote(new CSingNotes(sb, PartyModeID), sb.Name); foreach (SThemeSongMenu sm in Theme.SongMenus) - _AddSongMenu(CSongMenuFactory.CreateSongMenu(sm, PartyModeID), sm.Name); + _AddSongMenu(new CSongMenu(sm, PartyModeID), sm.Name); foreach (SThemeStatic st in Theme.Statics) _AddStatic(new CStatic(st, PartyModeID), st.Name); @@ -258,14 +258,7 @@ namespace VocaluxeLib.Menu _LoadThemeElement(_ThemeTexts, _AddText, xmlReader); _LoadThemeElement(_ThemeButtons, _AddButton, xmlReader); _LoadThemeElement(_ThemeSelectSlides, _AddSelectSlide, xmlReader); - foreach (string elName in _ThemeSongMenus) - { - ISongMenu element = CSongMenuFactory.CreateSongMenu(PartyModeID); - if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader)) - _AddSongMenu(element, elName); - else - CBase.Log.LogError("Can't load songmenu \"" + elName + "\" in screen " + ThemeName); - } + _LoadThemeElement(_ThemeSongMenus, _AddSongMenu, xmlReader); _LoadThemeElement(_ThemeSongMenus, _AddSongMenu, xmlReader); _LoadThemeElement(_ThemeLyrics, _AddLyric, xmlReader); _LoadThemeElement(_ThemeSingNotes, _AddSingNote, xmlReader); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs new file mode 100644 index 00000000..7dfd0dad --- /dev/null +++ b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs @@ -0,0 +1,238 @@ +#region license +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +#endregion + +using System; +using VocaluxeLib.PartyModes; +using VocaluxeLib.Xml; + +namespace VocaluxeLib.Menu.SongMenu +{ + public class CSongMenu : ISongMenu + { + private readonly int _PartyModeID; + private ISongMenu _SongMenu; + + /// + /// Deprecated! Only used for old theme loading. + /// + /// + public CSongMenu(int partyModeID) + { + _PartyModeID = partyModeID; + _SongMenu = new CSongMenuTileBoard(partyModeID); + } + + public CSongMenu(SThemeSongMenu theme, int partyModeID) + { + _PartyModeID = partyModeID; + _CreateSongMenu(theme); + CBase.Config.AddSongMenuListener(_OnSongMenuChanged); + } + + #region ISongMenu + public bool SmallView + { + get { return _SongMenu.SmallView; } + set { _SongMenu.SmallView = value; } + } + + public void Update(SScreenSongOptions songOptions) + { + _SongMenu.Update(songOptions); + } + + public void OnShow() + { + _SongMenu.OnShow(); + } + + public void OnHide() + { + _SongMenu.OnHide(); + } + + public bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options) + { + return _SongMenu.HandleInput(ref keyEvent, options); + } + + public bool HandleMouse(ref SMouseEvent mouseEvent, SScreenSongOptions songOptions) + { + return _SongMenu.HandleMouse(ref mouseEvent, songOptions); + } + + public void Draw() + { + _SongMenu.Draw(); + } + + public bool IsMouseOverSelectedSong(SMouseEvent mEvent) + { + return _SongMenu.IsMouseOverSelectedSong(mEvent); + } + + public int GetPreviewSongNr() + { + return _SongMenu.GetPreviewSongNr(); + } + + public int GetSelectedSongNr() + { + return _SongMenu.GetSelectedSongNr(); + } + + public CStatic GetSelectedSongCover() + { + return _SongMenu.GetSelectedSongCover(); + } + + public void SetSelectedSong(int visibleSongNr) + { + _SongMenu.SetSelectedSong(visibleSongNr); + } + + public int GetSelectedCategory() + { + return _SongMenu.GetSelectedCategory(); + } + + public void SetSelectedCategory(int categoryNr) + { + _SongMenu.SetSelectedCategory(categoryNr); + } + + public bool EnterSelectedCategory() + { + return _SongMenu.EnterSelectedCategory(); + } + + public int GetPreviewSong() + { + return _SongMenu.GetPreviewSong(); + } + #endregion ISongMenu + + #region IMenuElement + public bool Highlighted + { + get { return _SongMenu.Highlighted; } + set { _SongMenu.Highlighted = value; } + } + public bool Selected + { + get { return _SongMenu.Selected; } + set { _SongMenu.Selected = value; } + } + + public bool Selectable + { + get { return _SongMenu.Selectable; } + } + public bool Visible + { + get { return _SongMenu.Visible; } + set { _SongMenu.Visible = value; } + } + + public SRectF Rect + { + get { return _SongMenu.Rect; } + } + public SRectF MaxRect + { + get { return _SongMenu.MaxRect; } + set { _SongMenu.MaxRect = value; } + } + #endregion IMenuElement + + #region IThemeable + public string GetThemeName() + { + return _SongMenu.GetThemeName(); + } + + public object GetTheme() + { + return _SongMenu.GetTheme(); + } + + public bool ThemeLoaded + { + get { return _SongMenu.ThemeLoaded; } + } + + public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader) + { + return _SongMenu.LoadTheme(xmlPath, elementName, xmlReader); + } + + public void UnloadSkin() + { + _SongMenu.UnloadSkin(); + } + + public void LoadSkin() + { + _SongMenu.LoadSkin(); + } + + public void ReloadSkin() + { + _SongMenu.ReloadSkin(); + } + + public void MoveElement(int stepX, int stepY) + { + _SongMenu.MoveElement(stepX, stepY); + } + + public void ResizeElement(int stepW, int stepH) + { + _SongMenu.ResizeElement(stepW, stepH); + } + #endregion IThemeable + + private void _OnSongMenuChanged() + { + _CreateSongMenu((SThemeSongMenu)_SongMenu.GetTheme()); + _SongMenu.LoadSkin(); + } + + private void _CreateSongMenu(SThemeSongMenu theme) + { + switch (CBase.Config.GetSongMenuType()) + { + case ESongMenu.TR_CONFIG_LIST: + _SongMenu = new CSongMenuList(theme, _PartyModeID); + break; + + //case ESongMenu.TR_CONFIG_DREIDEL: + // _SongMenu = new CSongMenuDreidel(); + // break; + case ESongMenu.TR_CONFIG_TILE_BOARD: + _SongMenu = new CSongMenuTileBoard(theme, _PartyModeID); + break; + + //case ESongMenu.TR_CONFIG_BOOK: + // _SongMenu = new CSongMenuBook(); + // break; + default: + throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType()); + } + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs deleted file mode 100644 index a74d4913..00000000 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs +++ /dev/null @@ -1,70 +0,0 @@ -#region license -// This file is part of Vocaluxe. -// -// Vocaluxe is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Vocaluxe is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Vocaluxe. If not, see . -#endregion - -using System; - -namespace VocaluxeLib.Menu.SongMenu -{ - public static class CSongMenuFactory - { - public static ISongMenu CreateSongMenu(SThemeSongMenu theme, int partyModeID) - { - switch (CBase.Config.GetSongMenuType()) - { - case ESongMenu.TR_CONFIG_LIST: - return new CSongMenuList(theme, partyModeID); - - //case ESongMenu.TR_CONFIG_DREIDEL: - // _SongMenu = new CSongMenuDreidel(); - // break; - case ESongMenu.TR_CONFIG_TILE_BOARD: - return new CSongMenuTileBoard(theme, partyModeID); - - //case ESongMenu.TR_CONFIG_BOOK: - // _SongMenu = new CSongMenuBook(); - // break; - } - throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType()); - } - - /// - /// Deprecated! Only used for old theme loading. - /// - /// - /// - public static ISongMenu CreateSongMenu(int partyModeID) - { - switch (CBase.Config.GetSongMenuType()) - { - //case ESongMenu.TR_CONFIG_LIST: - // _SongMenu = new CSongMenuList(); - // break; - - //case ESongMenu.TR_CONFIG_DREIDEL: - // _SongMenu = new CSongMenuDreidel(); - // break; - case ESongMenu.TR_CONFIG_TILE_BOARD: - return new CSongMenuTileBoard(partyModeID); - - //case ESongMenu.TR_CONFIG_BOOK: - // _SongMenu = new CSongMenuBook(); - // break; - } - throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType()); - } - } -} \ No newline at end of file diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index 3eb458fa..5b6cec3f 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -108,6 +108,7 @@ + @@ -128,7 +129,6 @@ - From 903c4fc182003ade1e4d539dec2e35115b9858b2 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 10 Dec 2014 21:45:27 +0100 Subject: [PATCH 11/21] Remove proxy songmenu class --- Vocaluxe/Base/CMain.cs | 5 + Vocaluxe/Screens/CScreenSong.cs | 6 + VocaluxeLib/IBasic.cs | 2 + VocaluxeLib/Menu/CMenu.cs | 27 +- VocaluxeLib/Menu/COrderedDictionaryLite.cs | 5 + VocaluxeLib/Menu/SongMenu/CSongMenu.cs | 238 ------------------ VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs | 54 ++++ VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 3 +- VocaluxeLib/VocaluxeLib.csproj | 2 +- 9 files changed, 99 insertions(+), 243 deletions(-) delete mode 100644 VocaluxeLib/Menu/SongMenu/CSongMenu.cs create mode 100644 VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 58f140bc..fab4eaa0 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -160,6 +160,11 @@ namespace Vocaluxe.Base { CConfig.SongMenuChanged += onSongMenuChanged; } + + public void RemoveSongMenuListener(OnSongMenuChanged onSongMenuChanged) + { + CConfig.SongMenuChanged -= onSongMenuChanged; + } } class CBsettings : ISettings diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 75dea6b9..3445c25c 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -147,6 +147,12 @@ namespace Vocaluxe.Screens _DragAndDropCover = GetNewStatic(); } + protected override void _OnSongMenuChanged() + { + base._OnSongMenuChanged(); + _SongMenu = _SongMenus[_SongMenuName]; + } + public override void LoadTheme(string xmlPath) { base.LoadTheme(xmlPath); diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index c3f1fbc1..ef287370 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -28,6 +28,7 @@ using VocaluxeLib.Songs; namespace VocaluxeLib { public delegate void OnSongMenuChanged(); + public interface IConfig { EOffOn GetSaveModifiedSongs(); @@ -60,6 +61,7 @@ namespace VocaluxeLib bool GetLoadOldThemeFiles(); void AddSongMenuListener(OnSongMenuChanged onSongMenuChanged); + void RemoveSongMenuListener(OnSongMenuChanged onSongMenuChanged); } public interface ISettings diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index 4c100a12..5bfc1c2f 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -89,6 +89,12 @@ namespace VocaluxeLib.Menu protected CMenu() { PartyModeID = -1; + CBase.Config.AddSongMenuListener(_OnSongMenuChanged); + } + + ~CMenu() + { + CBase.Config.RemoveSongMenuListener(_OnSongMenuChanged); } public override void Init() @@ -113,6 +119,16 @@ namespace VocaluxeLib.Menu _ThemeScreenSettings = null; } + protected virtual void _OnSongMenuChanged() + { + for (int i = 0; i < _SongMenus.Count; i++) + { + SThemeSongMenu theme = (SThemeSongMenu)_SongMenus[i].GetTheme(); + _SongMenus[i] = CSongMenuFactory.CreateSongMenu(theme, PartyModeID); + _SongMenus[i].LoadSkin(); + } + } + #region ThemeHandler protected override void _ClearElements() { @@ -201,7 +217,7 @@ namespace VocaluxeLib.Menu _AddSingNote(new CSingNotes(sb, PartyModeID), sb.Name); foreach (SThemeSongMenu sm in Theme.SongMenus) - _AddSongMenu(new CSongMenu(sm, PartyModeID), sm.Name); + _AddSongMenu(CSongMenuFactory.CreateSongMenu(sm, PartyModeID), sm.Name); foreach (SThemeStatic st in Theme.Statics) _AddStatic(new CStatic(st, PartyModeID), st.Name); @@ -258,7 +274,14 @@ namespace VocaluxeLib.Menu _LoadThemeElement(_ThemeTexts, _AddText, xmlReader); _LoadThemeElement(_ThemeButtons, _AddButton, xmlReader); _LoadThemeElement(_ThemeSelectSlides, _AddSelectSlide, xmlReader); - _LoadThemeElement(_ThemeSongMenus, _AddSongMenu, xmlReader); + foreach (string elName in _ThemeSongMenus) + { + ISongMenu element = CSongMenuFactory.CreateSongMenu(PartyModeID); + if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader)) + _AddSongMenu(element, elName); + else + CBase.Log.LogError("Can't load songmenu \"" + elName + "\" in screen " + ThemeName); + } _LoadThemeElement(_ThemeSongMenus, _AddSongMenu, xmlReader); _LoadThemeElement(_ThemeLyrics, _AddLyric, xmlReader); _LoadThemeElement(_ThemeSingNotes, _AddSingNote, xmlReader); diff --git a/VocaluxeLib/Menu/COrderedDictionaryLite.cs b/VocaluxeLib/Menu/COrderedDictionaryLite.cs index d1d5463f..3bb7d995 100644 --- a/VocaluxeLib/Menu/COrderedDictionaryLite.cs +++ b/VocaluxeLib/Menu/COrderedDictionaryLite.cs @@ -36,6 +36,11 @@ namespace VocaluxeLib.Menu _ParentName = _ParentName.Remove(0, 1); } + public int Count + { + get { return _Items.Count; } + } + public T this[int index] { get { return _Items[index]; } diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs b/VocaluxeLib/Menu/SongMenu/CSongMenu.cs deleted file mode 100644 index 7dfd0dad..00000000 --- a/VocaluxeLib/Menu/SongMenu/CSongMenu.cs +++ /dev/null @@ -1,238 +0,0 @@ -#region license -// This file is part of Vocaluxe. -// -// Vocaluxe is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// Vocaluxe is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with Vocaluxe. If not, see . -#endregion - -using System; -using VocaluxeLib.PartyModes; -using VocaluxeLib.Xml; - -namespace VocaluxeLib.Menu.SongMenu -{ - public class CSongMenu : ISongMenu - { - private readonly int _PartyModeID; - private ISongMenu _SongMenu; - - /// - /// Deprecated! Only used for old theme loading. - /// - /// - public CSongMenu(int partyModeID) - { - _PartyModeID = partyModeID; - _SongMenu = new CSongMenuTileBoard(partyModeID); - } - - public CSongMenu(SThemeSongMenu theme, int partyModeID) - { - _PartyModeID = partyModeID; - _CreateSongMenu(theme); - CBase.Config.AddSongMenuListener(_OnSongMenuChanged); - } - - #region ISongMenu - public bool SmallView - { - get { return _SongMenu.SmallView; } - set { _SongMenu.SmallView = value; } - } - - public void Update(SScreenSongOptions songOptions) - { - _SongMenu.Update(songOptions); - } - - public void OnShow() - { - _SongMenu.OnShow(); - } - - public void OnHide() - { - _SongMenu.OnHide(); - } - - public bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options) - { - return _SongMenu.HandleInput(ref keyEvent, options); - } - - public bool HandleMouse(ref SMouseEvent mouseEvent, SScreenSongOptions songOptions) - { - return _SongMenu.HandleMouse(ref mouseEvent, songOptions); - } - - public void Draw() - { - _SongMenu.Draw(); - } - - public bool IsMouseOverSelectedSong(SMouseEvent mEvent) - { - return _SongMenu.IsMouseOverSelectedSong(mEvent); - } - - public int GetPreviewSongNr() - { - return _SongMenu.GetPreviewSongNr(); - } - - public int GetSelectedSongNr() - { - return _SongMenu.GetSelectedSongNr(); - } - - public CStatic GetSelectedSongCover() - { - return _SongMenu.GetSelectedSongCover(); - } - - public void SetSelectedSong(int visibleSongNr) - { - _SongMenu.SetSelectedSong(visibleSongNr); - } - - public int GetSelectedCategory() - { - return _SongMenu.GetSelectedCategory(); - } - - public void SetSelectedCategory(int categoryNr) - { - _SongMenu.SetSelectedCategory(categoryNr); - } - - public bool EnterSelectedCategory() - { - return _SongMenu.EnterSelectedCategory(); - } - - public int GetPreviewSong() - { - return _SongMenu.GetPreviewSong(); - } - #endregion ISongMenu - - #region IMenuElement - public bool Highlighted - { - get { return _SongMenu.Highlighted; } - set { _SongMenu.Highlighted = value; } - } - public bool Selected - { - get { return _SongMenu.Selected; } - set { _SongMenu.Selected = value; } - } - - public bool Selectable - { - get { return _SongMenu.Selectable; } - } - public bool Visible - { - get { return _SongMenu.Visible; } - set { _SongMenu.Visible = value; } - } - - public SRectF Rect - { - get { return _SongMenu.Rect; } - } - public SRectF MaxRect - { - get { return _SongMenu.MaxRect; } - set { _SongMenu.MaxRect = value; } - } - #endregion IMenuElement - - #region IThemeable - public string GetThemeName() - { - return _SongMenu.GetThemeName(); - } - - public object GetTheme() - { - return _SongMenu.GetTheme(); - } - - public bool ThemeLoaded - { - get { return _SongMenu.ThemeLoaded; } - } - - public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader) - { - return _SongMenu.LoadTheme(xmlPath, elementName, xmlReader); - } - - public void UnloadSkin() - { - _SongMenu.UnloadSkin(); - } - - public void LoadSkin() - { - _SongMenu.LoadSkin(); - } - - public void ReloadSkin() - { - _SongMenu.ReloadSkin(); - } - - public void MoveElement(int stepX, int stepY) - { - _SongMenu.MoveElement(stepX, stepY); - } - - public void ResizeElement(int stepW, int stepH) - { - _SongMenu.ResizeElement(stepW, stepH); - } - #endregion IThemeable - - private void _OnSongMenuChanged() - { - _CreateSongMenu((SThemeSongMenu)_SongMenu.GetTheme()); - _SongMenu.LoadSkin(); - } - - private void _CreateSongMenu(SThemeSongMenu theme) - { - switch (CBase.Config.GetSongMenuType()) - { - case ESongMenu.TR_CONFIG_LIST: - _SongMenu = new CSongMenuList(theme, _PartyModeID); - break; - - //case ESongMenu.TR_CONFIG_DREIDEL: - // _SongMenu = new CSongMenuDreidel(); - // break; - case ESongMenu.TR_CONFIG_TILE_BOARD: - _SongMenu = new CSongMenuTileBoard(theme, _PartyModeID); - break; - - //case ESongMenu.TR_CONFIG_BOOK: - // _SongMenu = new CSongMenuBook(); - // break; - default: - throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType()); - } - } - } -} \ No newline at end of file diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs new file mode 100644 index 00000000..fe4bbb73 --- /dev/null +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFactory.cs @@ -0,0 +1,54 @@ +#region license +// This file is part of Vocaluxe. +// +// Vocaluxe is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Vocaluxe is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with Vocaluxe. If not, see . +#endregion + +using System; + +namespace VocaluxeLib.Menu.SongMenu +{ + public static class CSongMenuFactory + { + public static ISongMenu CreateSongMenu(SThemeSongMenu theme, int partyModeID) + { + switch (CBase.Config.GetSongMenuType()) + { + case ESongMenu.TR_CONFIG_LIST: + return new CSongMenuList(theme, partyModeID); + + //case ESongMenu.TR_CONFIG_DREIDEL: + // _SongMenu = new CSongMenuDreidel(); + // break; + case ESongMenu.TR_CONFIG_TILE_BOARD: + return new CSongMenuTileBoard(theme, partyModeID); + + //case ESongMenu.TR_CONFIG_BOOK: + // _SongMenu = new CSongMenuBook(); + // break; + } + throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType()); + } + + /// + /// Deprecated! Only used for old theme loading. + /// + /// + /// + public static ISongMenu CreateSongMenu(int partyModeID) + { + return new CSongMenuTileBoard(partyModeID); + } + } +} \ No newline at end of file diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index cd5f6eb0..836e7e9a 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -638,14 +638,13 @@ namespace VocaluxeLib.Menu.SongMenu public override void LoadSkin() { - base.LoadSkin(); foreach (IThemeable themeable in _SubElements.OfType()) themeable.LoadSkin(); // Those are drawn seperately so they are not in the above list _CoverBig.LoadSkin(); _TextBG.LoadSkin(); - Init(); + base.LoadSkin(); } } } \ No newline at end of file diff --git a/VocaluxeLib/VocaluxeLib.csproj b/VocaluxeLib/VocaluxeLib.csproj index 5b6cec3f..3eb458fa 100644 --- a/VocaluxeLib/VocaluxeLib.csproj +++ b/VocaluxeLib/VocaluxeLib.csproj @@ -108,7 +108,6 @@ - @@ -129,6 +128,7 @@ + From 80b9422fb0a0de51b15aa96c7f4b8f4c1254bd6f Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 10 Dec 2014 21:58:16 +0100 Subject: [PATCH 12/21] Fix scrolling and hide empty tiles --- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 836e7e9a..9bef156d 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -579,18 +579,13 @@ namespace VocaluxeLib.Menu.SongMenu _UpdateList(true); } - private int _GetOffsetForPosition(int index, int rowNum = 0) - { - return (index / 1) * 1 - (1 * rowNum.Clamp(0, _ListLength - 1, true)); - } - private void _UpdateList(bool force = false) { int offset; if (_SelectionNr < _Offset && _SelectionNr >= 0) - offset = _GetOffsetForPosition(_SelectionNr); - else if (_SelectionNr >= _Offset + 1 * _ListLength) - offset = _GetOffsetForPosition(_SelectionNr, _ListLength); + offset = _SelectionNr; + else if (_SelectionNr >= _Offset + _ListLength) + offset = _SelectionNr - _ListLength + 1; else offset = _Offset; _UpdateList(offset, force); @@ -601,7 +596,7 @@ namespace VocaluxeLib.Menu.SongMenu bool isInCategory = CBase.Songs.IsInCategory(); int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); - offset = offset.Clamp(0, _GetOffsetForPosition(itemCount, _ListLength - 1), true); + offset = offset.Clamp(0, itemCount - _ListLength, true); if (offset == _Offset && !force) return; @@ -628,8 +623,7 @@ namespace VocaluxeLib.Menu.SongMenu } else { - _Tiles[i].Texture = _CoverBGTexture; - _Tiles[i].Color = _Color; + _Tiles[i].Color.A = 0; _Texts[i].Text = ""; } } From 42d98070f9e0ce4fc11b621d6711f2034683d5c6 Mon Sep 17 00:00:00 2001 From: mephasor Date: Sat, 13 Dec 2014 12:34:11 -0400 Subject: [PATCH 13/21] - Clened the list menu code a tiny bit - Added song number and total song count to the bottom text (instead of a scroll bar) --- Vocaluxe/Screens/CScreenSong.cs | 2 +- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 3445c25c..351ab2b3 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -680,7 +680,7 @@ namespace Vocaluxe.Screens { int song = _SongMenu.GetSelectedSongNr(); if (song >= 0 && song < CSongs.VisibleSongs.Count) - selectionText = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title; + selectionText = CSongs.VisibleSongs[song].Artist + " - " + CSongs.VisibleSongs[song].Title + " ( "+(song+1)+" / "+CSongs.NumAllSongs+" )"; } else { diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 9bef156d..eb4151e2 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -50,7 +50,6 @@ namespace VocaluxeLib.Menu.SongMenu private int _TileW; private int _TileH; - //TODO: remove all 1* from the code (artifacts from translation from tile board) //TODO: make variable list length private int _ListLength = 15; private float _CoverTileWidth; @@ -183,7 +182,6 @@ namespace VocaluxeLib.Menu.SongMenu //Create text var textRect = new SRectF(Rect.X + 2 * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _ListTextWidth, _TileH, Rect.Z); - //string textString = _Artist.Text + " - " + _Title.Text; CText text = new CText(textRect.X, textRect.Y, textRect.Z, textRect.H, textRect.W, EAlignment.Left, EStyle.Normal, "Normal", _Artist.Color, ""); @@ -421,7 +419,7 @@ namespace VocaluxeLib.Menu.SongMenu if (!songOptions.Selection.RandomOnly || (!CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed)) { if (mouseEvent.Wheel != 0 && CHelper.IsInBounds(_ScrollRect, mouseEvent)) - _UpdateList(_Offset + 1 * mouseEvent.Wheel); + _UpdateList(_Offset + mouseEvent.Wheel); int lastSelection = _SelectionNr; int i = 0; @@ -508,7 +506,6 @@ namespace VocaluxeLib.Menu.SongMenu text.Draw(); i++; } - _TextBG.Draw(); CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null; @@ -595,6 +592,7 @@ namespace VocaluxeLib.Menu.SongMenu { bool isInCategory = CBase.Songs.IsInCategory(); int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories(); + int totalSongNumber = CBase.Songs.GetNumSongs(); offset = offset.Clamp(0, itemCount - _ListLength, true); From ec791c100e7ad6cee868c613a4f94963f0278d00 Mon Sep 17 00:00:00 2001 From: mephasor Date: Sat, 13 Dec 2014 15:47:28 -0400 Subject: [PATCH 14/21] Extracted List View parameters to ScreenSong.xml --- Output/Themes/Ambient/Screens/ScreenSong.xml | 124 +++++++++++++++++- .../Menu/SongMenu/CSongMenuFramework.cs | 45 ++++++- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 46 +++---- 3 files changed, 190 insertions(+), 25 deletions(-) diff --git a/Output/Themes/Ambient/Screens/ScreenSong.xml b/Output/Themes/Ambient/Screens/ScreenSong.xml index d9f45cd2..47cdc20d 100644 --- a/Output/Themes/Ambient/Screens/ScreenSong.xml +++ b/Output/Themes/Ambient/Screens/ScreenSong.xml @@ -810,7 +810,7 @@ 40 40 - 360 + 3600 550 -1 @@ -860,6 +860,128 @@ + + + 20 + 10 + 10 + + 410 + 40 + 830 + 550 + -1 + + + 222 + 416 + -1.01 + 39 + 340 + + + Center + Top + + Outline + + + + 222 + 456 + -1.01 + 32 + 340 + + + Center + Top + + Outline + + + + 222 + 490 + -1.01 + 28 + 340 + + + Center + Top + + Outline + + + + CoverBackground + + + 40 + 40 + 360 + 360 + -1 + + + + CoverBackground + + + 40 + 40 + 3600 + 550 + -1 + + + + DuetIcon + + + 200 + 530 + 40 + 40 + -1 + + + + VideoIcon + + + 120 + 530 + 40 + 40 + -1 + + + + MedleyCalcIcon + + + 280 + 530 + 40 + 40 + -1 + + + + MedleyTagIcon + + + 280 + 530 + 40 + 40 + -1 + + + + diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index d3668346..ec8d59cb 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -39,9 +39,40 @@ namespace VocaluxeLib.Menu.SongMenu //public SThemeSongMenuBook songMenuBook; //public SThemeSongMenuDreidel songMenuDreidel; - //public SThemeSongMenuList songMenuList; + public SThemeSongMenuList SongMenuList; public SThemeSongMenuTileBoard SongMenuTileBoard; } + public struct SThemeSongMenuList + { + /// + /// Number of visible songs in list + /// + public int ListLength; + + /// + /// Space between tiles horizontal + /// + public float SpaceW; + + /// + /// Space between tiles vertical + /// + public float SpaceH; + + public SRectF TileRect; + + public SThemeText TextArtist; + public SThemeText TextTitle; + public SThemeText TextSongLength; + + public SThemeStatic StaticCoverBig; + public SThemeStatic StaticTextBG; + public SThemeStatic StaticDuetIcon; + public SThemeStatic StaticVideoIcon; + public SThemeStatic StaticMedleyCalcIcon; + public SThemeStatic StaticMedleyTagIcon; + } + public struct SThemeSongMenuTileBoard { @@ -215,6 +246,18 @@ namespace VocaluxeLib.Menu.SongMenu ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuTileBoard/TileRectSmallH", ref _Theme.SongMenuTileBoard.TileRectSmall.H); #endregion SongMenuTileBoard + #region SongMenuList + ThemeLoaded &= xmlReader.TryGetIntValue(item + "/SongMenuList/ListLength", ref _Theme.SongMenuList.ListLength); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/SpaceW", ref _Theme.SongMenuList.SpaceW); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/SpaceH", ref _Theme.SongMenuList.SpaceH); + + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectX", ref _Theme.SongMenuList.TileRect.X); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectY", ref _Theme.SongMenuList.TileRect.Y); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectZ", ref _Theme.SongMenuList.TileRect.Z); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectW", ref _Theme.SongMenuList.TileRect.W); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectH", ref _Theme.SongMenuList.TileRect.H); + #endregion SongMenuList + if (ThemeLoaded) { _Theme.Name = elementName; diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index eb4151e2..c88f2d25 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -50,8 +50,7 @@ namespace VocaluxeLib.Menu.SongMenu private int _TileW; private int _TileH; - //TODO: make variable list length - private int _ListLength = 15; + private int _ListLength; private float _CoverTileWidth; private float _ListTextWidth; @@ -114,31 +113,32 @@ namespace VocaluxeLib.Menu.SongMenu public CSongMenuList(SThemeSongMenu theme, int partyModeID) : base(theme, partyModeID) { - _SpaceW = _Theme.SongMenuTileBoard.SpaceW; - _SpaceH = _Theme.SongMenuTileBoard.SpaceH; - _Artist = new CText(_Theme.SongMenuTileBoard.TextArtist, _PartyModeID); - _Title = new CText(_Theme.SongMenuTileBoard.TextTitle, _PartyModeID); - _SongLength = new CText(_Theme.SongMenuTileBoard.TextSongLength, _PartyModeID); - _CoverBig = new CStatic(_Theme.SongMenuTileBoard.StaticCoverBig, _PartyModeID); - _TextBG = new CStatic(_Theme.SongMenuTileBoard.StaticTextBG, _PartyModeID); - _DuetIcon = new CStatic(_Theme.SongMenuTileBoard.StaticDuetIcon, _PartyModeID); - _VideoIcon = new CStatic(_Theme.SongMenuTileBoard.StaticVideoIcon, _PartyModeID); - _MedleyCalcIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyCalcIcon, _PartyModeID); - _MedleyTagIcon = new CStatic(_Theme.SongMenuTileBoard.StaticMedleyTagIcon, _PartyModeID); + _ListLength = _Theme.SongMenuList.ListLength; + _SpaceW = _Theme.SongMenuList.SpaceW; + _SpaceH = _Theme.SongMenuList.SpaceH; + _Artist = new CText(_Theme.SongMenuList.TextArtist, _PartyModeID); + _Title = new CText(_Theme.SongMenuList.TextTitle, _PartyModeID); + _SongLength = new CText(_Theme.SongMenuList.TextSongLength, _PartyModeID); + _CoverBig = new CStatic(_Theme.SongMenuList.StaticCoverBig, _PartyModeID); + _TextBG = new CStatic(_Theme.SongMenuList.StaticTextBG, _PartyModeID); + _DuetIcon = new CStatic(_Theme.SongMenuList.StaticDuetIcon, _PartyModeID); + _VideoIcon = new CStatic(_Theme.SongMenuList.StaticVideoIcon, _PartyModeID); + _MedleyCalcIcon = new CStatic(_Theme.SongMenuList.StaticMedleyCalcIcon, _PartyModeID); + _MedleyTagIcon = new CStatic(_Theme.SongMenuList.StaticMedleyTagIcon, _PartyModeID); _SubElements.AddRange(new IMenuElement[] {_Artist, _Title, _SongLength, _DuetIcon, _VideoIcon, _MedleyCalcIcon, _MedleyTagIcon}); } private void _ReadSubTheme() { - _Theme.SongMenuTileBoard.TextArtist = (SThemeText)_Artist.GetTheme(); - _Theme.SongMenuTileBoard.TextSongLength = (SThemeText)_SongLength.GetTheme(); - _Theme.SongMenuTileBoard.TextTitle = (SThemeText)_Title.GetTheme(); - _Theme.SongMenuTileBoard.StaticCoverBig = (SThemeStatic)_CoverBig.GetTheme(); - _Theme.SongMenuTileBoard.StaticDuetIcon = (SThemeStatic)_DuetIcon.GetTheme(); - _Theme.SongMenuTileBoard.StaticMedleyCalcIcon = (SThemeStatic)_MedleyCalcIcon.GetTheme(); - _Theme.SongMenuTileBoard.StaticMedleyTagIcon = (SThemeStatic)_MedleyTagIcon.GetTheme(); - _Theme.SongMenuTileBoard.StaticTextBG = (SThemeStatic)_TextBG.GetTheme(); - _Theme.SongMenuTileBoard.StaticVideoIcon = (SThemeStatic)_VideoIcon.GetTheme(); + _Theme.SongMenuList.TextArtist = (SThemeText)_Artist.GetTheme(); + _Theme.SongMenuList.TextSongLength = (SThemeText)_SongLength.GetTheme(); + _Theme.SongMenuList.TextTitle = (SThemeText)_Title.GetTheme(); + _Theme.SongMenuList.StaticCoverBig = (SThemeStatic)_CoverBig.GetTheme(); + _Theme.SongMenuList.StaticDuetIcon = (SThemeStatic)_DuetIcon.GetTheme(); + _Theme.SongMenuList.StaticMedleyCalcIcon = (SThemeStatic)_MedleyCalcIcon.GetTheme(); + _Theme.SongMenuList.StaticMedleyTagIcon = (SThemeStatic)_MedleyTagIcon.GetTheme(); + _Theme.SongMenuList.StaticTextBG = (SThemeStatic)_TextBG.GetTheme(); + _Theme.SongMenuList.StaticVideoIcon = (SThemeStatic)_VideoIcon.GetTheme(); } public override object GetTheme() @@ -157,7 +157,7 @@ namespace VocaluxeLib.Menu.SongMenu private void _InitTiles() { - MaxRect = _Theme.SongMenuTileBoard.TileRect; + MaxRect = _Theme.SongMenuList.TileRect; //keep tile ratio 3/2 so the covers still look nice. _CoverTileWidth = _ListLength * 3.0f / 2; From d5c39ceb1af8617e358bc943534d9b0c6d116a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Sun, 21 Dec 2014 13:00:57 +0100 Subject: [PATCH 15/21] Fix double-click for starting song. --- VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs | 2 +- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index ec8d59cb..b1f5eed0 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -299,7 +299,7 @@ namespace VocaluxeLib.Menu.SongMenu CBase.Drawing.DrawTexture(CBase.BackgroundMusic.GetVideoTexture(), new SRectF(0, 0, 1280, 720, 0)); } - public bool IsMouseOverSelectedSong(SMouseEvent mEvent) + public virtual bool IsMouseOverSelectedSong(SMouseEvent mEvent) { CStatic selCov = GetSelectedSongCover(); return selCov != null && CHelper.IsInBounds(selCov.Rect.Scale(SelectedTileZoomFactor), mEvent); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index c88f2d25..7b52be5b 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -530,6 +530,17 @@ namespace VocaluxeLib.Menu.SongMenu return _Tiles.FirstOrDefault(tile => tile.Selected); } + public override bool IsMouseOverSelectedSong(SMouseEvent mEvent) + { + for (int i = 0; i < _Tiles.Count; i++) + { + if (!_Tiles[i].Selected) + continue; + return CHelper.IsInBounds(_Tiles[i].Rect, mEvent) || CHelper.IsInBounds(_Texts[i].Rect, mEvent); + } + return false; + } + protected override void _EnterCategory(int categoryNr) { base._EnterCategory(categoryNr); From 2a50aa6d3aee11f3f48a085a72fb4e108b200fbf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 22 Dec 2014 08:54:38 +0100 Subject: [PATCH 16/21] Bumped screen-version, fixed theme-issue. --- Output/Themes/Ambient/Screens/ScreenSong.xml | 8 ++++---- Output/Themes/Changelog/Changelog_ScreenSong.txt | 6 ++++++ Vocaluxe/Screens/CScreenSong.cs | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Output/Themes/Ambient/Screens/ScreenSong.xml b/Output/Themes/Ambient/Screens/ScreenSong.xml index e3b55063..d0e0b800 100644 --- a/Output/Themes/Ambient/Screens/ScreenSong.xml +++ b/Output/Themes/Ambient/Screens/ScreenSong.xml @@ -2,7 +2,7 @@ ScreenSong - 5 + 6 @@ -810,7 +810,7 @@ 40 40 - 3600 + 360 550 -1 @@ -931,7 +931,7 @@ 40 40 - 3600 + 360 550 -1 @@ -1399,4 +1399,4 @@ - \ No newline at end of file + diff --git a/Output/Themes/Changelog/Changelog_ScreenSong.txt b/Output/Themes/Changelog/Changelog_ScreenSong.txt index 84b853fb..4b71ef3c 100644 --- a/Output/Themes/Changelog/Changelog_ScreenSong.txt +++ b/Output/Themes/Changelog/Changelog_ScreenSong.txt @@ -1,5 +1,11 @@ ScreenSong +++++++++++ +Version 6: + +Add: + to + ++++++++++ Version 5: diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index 30e98025..3a8a1749 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -42,7 +42,7 @@ namespace Vocaluxe.Screens // Version number for theme files. Increment it, if you've changed something on the theme files! protected override int _ScreenVersion { - get { return 5; } + get { return 6; } } private const string _TextCategory = "TextCategory"; From 10915cf6b9396f6dc29be58b9a338d6b7cf94f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 22 Dec 2014 09:10:19 +0100 Subject: [PATCH 17/21] Added small-view to SongMenuList, this fixes some input-issues. --- Output/Themes/Ambient/Screens/ScreenSong.xml | 7 +++++++ VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs | 17 ++++++++++++----- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 2 +- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/Output/Themes/Ambient/Screens/ScreenSong.xml b/Output/Themes/Ambient/Screens/ScreenSong.xml index d0e0b800..d916bcd8 100644 --- a/Output/Themes/Ambient/Screens/ScreenSong.xml +++ b/Output/Themes/Ambient/Screens/ScreenSong.xml @@ -872,6 +872,13 @@ 550 -1 + + 410 + 40 + 555 + 550 + -1 + 222 416 diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index b1f5eed0..67dad6a8 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -60,6 +60,7 @@ namespace VocaluxeLib.Menu.SongMenu public float SpaceH; public SRectF TileRect; + public SRectF TileRectSmall; public SThemeText TextArtist; public SThemeText TextTitle; @@ -251,11 +252,17 @@ namespace VocaluxeLib.Menu.SongMenu ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/SpaceW", ref _Theme.SongMenuList.SpaceW); ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/SpaceH", ref _Theme.SongMenuList.SpaceH); - ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectX", ref _Theme.SongMenuList.TileRect.X); - ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectY", ref _Theme.SongMenuList.TileRect.Y); - ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectZ", ref _Theme.SongMenuList.TileRect.Z); - ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectW", ref _Theme.SongMenuList.TileRect.W); - ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectH", ref _Theme.SongMenuList.TileRect.H); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/X", ref _Theme.SongMenuList.TileRect.X); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/Y", ref _Theme.SongMenuList.TileRect.Y); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/Z", ref _Theme.SongMenuList.TileRect.Z); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/W", ref _Theme.SongMenuList.TileRect.W); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRect/H", ref _Theme.SongMenuList.TileRect.H); + + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/X", ref _Theme.SongMenuList.TileRectSmall.X); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/Y", ref _Theme.SongMenuList.TileRectSmall.Y); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/Z", ref _Theme.SongMenuList.TileRectSmall.Z); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/W", ref _Theme.SongMenuList.TileRectSmall.W); + ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SongMenuList/TileRectSmall/H", ref _Theme.SongMenuList.TileRectSmall.H); #endregion SongMenuList if (ThemeLoaded) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 7b52be5b..64201a37 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -157,7 +157,7 @@ namespace VocaluxeLib.Menu.SongMenu private void _InitTiles() { - MaxRect = _Theme.SongMenuList.TileRect; + MaxRect = SmallView ? _Theme.SongMenuList.TileRectSmall : _Theme.SongMenuList.TileRect; //keep tile ratio 3/2 so the covers still look nice. _CoverTileWidth = _ListLength * 3.0f / 2; From 9aeb5c55ab36abfb8a4acef646c1cdf244e18df0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 22 Dec 2014 10:08:40 +0100 Subject: [PATCH 18/21] - less entries to increase text-height (better readable) - added MaxW to texts --- Output/Themes/Ambient/Screens/ScreenSong.xml | 2 +- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Output/Themes/Ambient/Screens/ScreenSong.xml b/Output/Themes/Ambient/Screens/ScreenSong.xml index d916bcd8..536f5b06 100644 --- a/Output/Themes/Ambient/Screens/ScreenSong.xml +++ b/Output/Themes/Ambient/Screens/ScreenSong.xml @@ -862,7 +862,7 @@ - 20 + 15 10 10 diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 64201a37..d6464610 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -185,6 +185,8 @@ namespace VocaluxeLib.Menu.SongMenu CText text = new CText(textRect.X, textRect.Y, textRect.Z, textRect.H, textRect.W, EAlignment.Left, EStyle.Normal, "Normal", _Artist.Color, ""); + text.MaxRect = new SRectF(text.MaxRect.X, text.MaxRect.Y, MaxRect.W + MaxRect.X - text.Rect.X - 5f, text.MaxRect.H, text.MaxRect.Z); + text.ResizeAlign = EHAlignment.Center; _Texts.Add(text); } From 0f8d39854fe3a4a0d24f9cce4b6ce27e850baa99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 22 Dec 2014 10:15:02 +0100 Subject: [PATCH 19/21] Fix flickering of last entry if list beyond is empty- --- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index d6464610..04e06866 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -432,7 +432,7 @@ namespace VocaluxeLib.Menu.SongMenu //create a rect including the cover and text of the song. //(this way mouse over text should make a selection as well) SRectF songRect = new SRectF(tile.Rect.X, tile.Rect.Y, Rect.W, tile.Rect.H, tile.Rect.Z); - if (tile.Texture != _CoverBGTexture && CHelper.IsInBounds(songRect, mouseEvent)) + if (tile.Texture != _CoverBGTexture && CHelper.IsInBounds(songRect, mouseEvent) && tile.Color.A != 0) { somethingSelected = true; _SelectionNr = i + _Offset; From 27c1dc1aaa7de0fb77f2514fc568ebdc0d9e3e11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 22 Dec 2014 10:24:52 +0100 Subject: [PATCH 20/21] Change cover-size-calculation to have it squared. --- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index 04e06866..dbce2bbb 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -159,12 +159,10 @@ namespace VocaluxeLib.Menu.SongMenu { MaxRect = SmallView ? _Theme.SongMenuList.TileRectSmall : _Theme.SongMenuList.TileRect; - //keep tile ratio 3/2 so the covers still look nice. - _CoverTileWidth = _ListLength * 3.0f / 2; - _ListTextWidth = Rect.W - _ListTextWidth; + _ListTextWidth = MaxRect.W - _ListTextWidth; - _TileW = (int)((Rect.W - _SpaceW * (_CoverTileWidth - 1)) / _CoverTileWidth); - _TileH = (int)((Rect.H - _SpaceH * (_ListLength - 1)) / _ListLength); + _TileW = (int)((MaxRect.W - _SpaceW * (_ListLength - 1)) / _ListLength); + _TileH = _TileW _CoverBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBackground, _PartyModeID); _CoverBigBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBigBackground, _PartyModeID); @@ -181,7 +179,7 @@ namespace VocaluxeLib.Menu.SongMenu _Tiles.Add(tile); //Create text - var textRect = new SRectF(Rect.X + 2 * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _ListTextWidth, _TileH, Rect.Z); + var textRect = new SRectF(MaxRect.X + 2 * (_TileW + _SpaceW), Rect.Y + i * (_TileH + _SpaceH), _ListTextWidth, _TileH, Rect.Z); CText text = new CText(textRect.X, textRect.Y, textRect.Z, textRect.H, textRect.W, EAlignment.Left, EStyle.Normal, "Normal", _Artist.Color, ""); From 92660712d0aaef6d60cbea04c6fcb13070a0c445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20K=C3=BCpper?= Date: Mon, 22 Dec 2014 12:41:57 +0100 Subject: [PATCH 21/21] Fixed cover-size-calc. --- VocaluxeLib/Menu/SongMenu/CSongMenuList.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs index dbce2bbb..8d1b3821 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuList.cs @@ -161,8 +161,8 @@ namespace VocaluxeLib.Menu.SongMenu _ListTextWidth = MaxRect.W - _ListTextWidth; - _TileW = (int)((MaxRect.W - _SpaceW * (_ListLength - 1)) / _ListLength); - _TileH = _TileW + _TileW = (int)((MaxRect.H - _SpaceH * (_ListLength - 1)) / _ListLength); + _TileH = _TileW; _CoverBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBackground, _PartyModeID); _CoverBigBGTexture = CBase.Themes.GetSkinTexture(_Theme.CoverBigBackground, _PartyModeID);