Runtime and build - Move all projects to .NET 10 with SDK-style project files and a shared Directory.Build.props (WIN/LINUX, x86/x64 defines) - Load managed and unmanaged dependencies from libs/managed and libs/unmanaged through assembly and native library resolvers - Compile party modes with Roslyn instead of CodeDom - Update AppVeyor to the .NET 10 SDK and dotnet test - Download the FFmpeg and gstreamer runtimes from the dependencies repository during the build - Remove the VC++ 2015-2022 runtime check, no dependency needs it anymore Graphics and windowing - Replace the Direct3D 9 renderer with Direct3D 11 (Vortice) - Pace Direct3D 11 frames with a frame latency waitable swap chain - Move window, input and message boxes to SDL3 - Replace System.Drawing with SkiaSharp and WinForms with SDL3 and a software renderer Video and audio - Replace Acinerella with FFmpeg 8.1.3 (FFmpeg.AutoGen) - Add hardware accelerated video decoding (D3D11VA, DXVA2, VideoToolbox, VAAPI, VDPAU) with software fallback - Convert YUV video frames to RGB on the GPU in Direct3D 11 and OpenGL - Add the video options HardwareDecoding, GpuColorConversion, DecoderThreads and VideoDownscaleResolution - Update OpenAL to OpenTK 4 and NAudio recording to WasapiRecorder Fixes - Fix the song preview start and shorten the reporter buttons - Fix a crash when opening the highscore without a selected song - Use the options slide highlight in the party mode screens to avoid brightness flicker on VRR displays - Disable GameInput in the x86 build, SDL3 crashes in GameInputCreate on 32-bit systems with the GameInput runtime installed - Fix a truncation warning in PitchTracker
1537 lines
58 KiB
C#
1537 lines
58 KiB
C#
#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 <http://www.gnu.org/licenses/>.
|
|
#endregion
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Xml.Serialization;
|
|
using VocaluxeLib.Songs;
|
|
|
|
namespace VocaluxeLib.Menu
|
|
{
|
|
public enum EEditMode
|
|
{
|
|
None,
|
|
PlaylistName,
|
|
ChangeOrder
|
|
}
|
|
|
|
public class CPlaylistSong
|
|
{
|
|
public int SongId;
|
|
public EGameMode GameMode;
|
|
public EAudioMode AudioMode;
|
|
|
|
public CPlaylistSong(int songId, EGameMode gm)
|
|
{
|
|
SongId = songId;
|
|
GameMode = gm;
|
|
AudioMode = EAudioMode.TR_AUDIOMODE_NORMAL;
|
|
}
|
|
|
|
public CPlaylistSong()
|
|
{
|
|
GameMode = EGameMode.TR_GAMEMODE_NORMAL;
|
|
AudioMode = EAudioMode.TR_AUDIOMODE_NORMAL;
|
|
}
|
|
|
|
public SPlaylistSong ToStruct()
|
|
{
|
|
var song = CBase.Songs.GetSongById(SongId);
|
|
if (song == null)
|
|
{
|
|
throw new Exception("Can't find Song. This should never happen!");
|
|
}
|
|
|
|
return new SPlaylistSong { Artist = song.Artist, Title = song.Title, GameMode = GameMode, AudioMode = AudioMode };
|
|
}
|
|
}
|
|
|
|
[XmlType("Playlist")]
|
|
public struct SThemePlaylist
|
|
{
|
|
[XmlAttribute(AttributeName = "Name")]
|
|
public string Name;
|
|
|
|
public SRectF Rect;
|
|
|
|
public float EntryHeight;
|
|
|
|
public string SkinBackground;
|
|
public string SkinBackgroundSelected;
|
|
|
|
public SThemeColor ColorBackground;
|
|
public SThemeColor SelColorBackground;
|
|
|
|
public SThemeText Text1;
|
|
|
|
public SThemeStatic StaticCover;
|
|
public SThemeStatic StaticPlaylistHeader;
|
|
public SThemeStatic StaticPlaylistFooter;
|
|
|
|
public SThemeButton ButtonPlaylistName;
|
|
public SThemeButton ButtonPlaylistClose;
|
|
public SThemeButton ButtonPlaylistSave;
|
|
public SThemeButton ButtonPlaylistDelete;
|
|
public SThemeButton ButtonPlaylistSing;
|
|
public SThemeButton ButtonPlaylistList;
|
|
|
|
public SThemeSelectSlide SelectSlideGameMode;
|
|
public SThemeSelectSlide? SelectSlideAudioMode;
|
|
}
|
|
|
|
//TODO: Refactor this class, it is almost unreadable and may not work in some occasions
|
|
public class CPlaylist : CObjectInteractions, IMenuElement, IThemeable
|
|
{
|
|
private class CPlaylistElementContent
|
|
{
|
|
public IList<EGameMode> Modes;
|
|
public int SongId;
|
|
public EGameMode Mode;
|
|
public EAudioMode AudioMode;
|
|
}
|
|
|
|
private class CPlaylistElement
|
|
{
|
|
public CStatic Cover;
|
|
public CStatic Background;
|
|
public CText Text1;
|
|
public CSelectSlide SelectSlide;
|
|
public CSelectSlide SelectSlideAudio;
|
|
public int Content;
|
|
|
|
public CPlaylistElement() { }
|
|
|
|
public CPlaylistElement(CPlaylistElement pe)
|
|
{
|
|
Cover = new CStatic(pe.Cover);
|
|
Background = new CStatic(pe.Background);
|
|
Text1 = new CText(pe.Text1);
|
|
SelectSlide = new CSelectSlide(pe.SelectSlide);
|
|
SelectSlideAudio = pe.SelectSlideAudio == null ? null : new CSelectSlide(pe.SelectSlideAudio);
|
|
Content = pe.Content;
|
|
}
|
|
|
|
public void Draw()
|
|
{
|
|
Background.Draw();
|
|
SelectSlide.Draw();
|
|
SelectSlideAudio?.Draw();
|
|
Cover.Draw();
|
|
Text1.Draw();
|
|
}
|
|
|
|
public void MouseMove(int posX, int posY, int oldPosX, int oldPosY)
|
|
{
|
|
var diffX = posX - oldPosX;
|
|
var diffY = posY - oldPosY;
|
|
|
|
Cover.X += diffX;
|
|
Cover.Y += diffY;
|
|
|
|
Background.X += diffX;
|
|
Background.Y += diffY;
|
|
|
|
SelectSlide.X += diffX;
|
|
SelectSlide.Y += diffY;
|
|
|
|
if (SelectSlideAudio != null)
|
|
{
|
|
SelectSlideAudio.X += diffX;
|
|
SelectSlideAudio.Y += diffY;
|
|
}
|
|
|
|
Text1.X += diffX;
|
|
Text1.Y += diffY;
|
|
}
|
|
}
|
|
|
|
private readonly int _PartyModeId;
|
|
private SThemePlaylist _Theme;
|
|
|
|
public string GetThemeName()
|
|
{
|
|
return _Theme.Name;
|
|
}
|
|
|
|
public bool ThemeLoaded { get; private set; }
|
|
|
|
private readonly List<CPlaylistElement> _PlaylistElements = new List<CPlaylistElement>();
|
|
private readonly List<CPlaylistElementContent> _PlaylistElementContents = new List<CPlaylistElementContent>();
|
|
|
|
private SRectF _CompleteRect;
|
|
private SColorF _BackgroundColor;
|
|
private SColorF _BackgroundSelColor;
|
|
|
|
private readonly CButton _ButtonPlaylistName;
|
|
private readonly CButton _ButtonPlaylistClose;
|
|
private readonly CButton _ButtonPlaylistSave;
|
|
private readonly CButton _ButtonPlaylistDelete;
|
|
private readonly CButton _ButtonPlaylistSing;
|
|
private readonly CButton _ButtonPlaylistList;
|
|
private readonly CText _Text1;
|
|
private readonly CSelectSlide _SelectSlideGameMode;
|
|
private readonly CSelectSlide _SelectSlideAudioMode;
|
|
private readonly CStatic _StaticPlaylistHeader;
|
|
private readonly CStatic _StaticPlaylistFooter;
|
|
|
|
public SRectF Rect
|
|
{
|
|
get { return _CompleteRect; }
|
|
}
|
|
public SRectF MaxRect { get; set; }
|
|
private bool _Selectable = true;
|
|
public bool Selectable
|
|
{
|
|
get { return Visible && _Selectable; }
|
|
set { _Selectable = value; }
|
|
}
|
|
public bool Visible
|
|
{
|
|
get { return _Active; }
|
|
set { _Active = value; }
|
|
}
|
|
public bool Highlighted { get; set; }
|
|
private bool _Selected;
|
|
public bool Selected
|
|
{
|
|
get { return _Selected; }
|
|
set
|
|
{
|
|
_Selected = value;
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
|
|
if (!value)
|
|
{
|
|
if (_EditMode == EEditMode.ChangeOrder && _ChangeOrderSource != -1 && _PlaylistElements.Count > _ChangeOrderSource)
|
|
{
|
|
CBase.Playlist.DeleteSong(ActivePlaylistId, _PlaylistElements[_ChangeOrderSource].Content);
|
|
UpdatePlaylist();
|
|
}
|
|
|
|
_ChangeOrderSource = -1;
|
|
_ChangeOrderElement = null;
|
|
_EditMode = EEditMode.None;
|
|
}
|
|
else if (_CurrentPlaylistElement == -1 && _PlaylistElements.Count > 0)
|
|
{
|
|
_SelectElement(_PlaylistElements[0].SelectSlide);
|
|
}
|
|
}
|
|
}
|
|
|
|
private EEditMode _EditMode;
|
|
public int ActivePlaylistId = -1;
|
|
private int _Offset;
|
|
private int _CurrentPlaylistElement = -1;
|
|
|
|
private CPlaylistElement _ChangeOrderElement;
|
|
private int _ChangeOrderSource = -1;
|
|
private int _OldMousePosX;
|
|
private int _OldMousePosY;
|
|
|
|
public int DragAndDropSongId = -1;
|
|
|
|
//private static
|
|
public CPlaylist(int partyModeId)
|
|
{
|
|
_PartyModeId = partyModeId;
|
|
|
|
_Text1 = new CText(_PartyModeId);
|
|
_StaticPlaylistFooter = new CStatic(_PartyModeId);
|
|
_StaticPlaylistHeader = new CStatic(_PartyModeId);
|
|
_ButtonPlaylistName = new CButton(_PartyModeId);
|
|
_ButtonPlaylistClose = new CButton(_PartyModeId);
|
|
_ButtonPlaylistDelete = new CButton(_PartyModeId);
|
|
_ButtonPlaylistSave = new CButton(_PartyModeId);
|
|
_ButtonPlaylistSing = new CButton(_PartyModeId);
|
|
_ButtonPlaylistList = new CButton(_PartyModeId);
|
|
_SelectSlideGameMode = new CSelectSlide(_PartyModeId);
|
|
|
|
Visible = false;
|
|
Selected = false;
|
|
}
|
|
|
|
public CPlaylist(SThemePlaylist theme, int partyModeId)
|
|
{
|
|
_PartyModeId = partyModeId;
|
|
_Theme = theme;
|
|
|
|
_Text1 = new CText(_Theme.Text1, _PartyModeId);
|
|
_StaticPlaylistFooter = new CStatic(_Theme.StaticPlaylistFooter, _PartyModeId);
|
|
_StaticPlaylistHeader = new CStatic(_Theme.StaticPlaylistHeader, _PartyModeId);
|
|
_ButtonPlaylistName = new CButton(_Theme.ButtonPlaylistName, _PartyModeId);
|
|
_ButtonPlaylistClose = new CButton(_Theme.ButtonPlaylistClose, _PartyModeId);
|
|
_ButtonPlaylistDelete = new CButton(_Theme.ButtonPlaylistDelete, _PartyModeId);
|
|
_ButtonPlaylistSave = new CButton(_Theme.ButtonPlaylistSave, _PartyModeId);
|
|
_ButtonPlaylistSing = new CButton(_Theme.ButtonPlaylistSing, _PartyModeId);
|
|
_ButtonPlaylistList = new CButton(_Theme.ButtonPlaylistList, _PartyModeId);
|
|
_SelectSlideGameMode = new CSelectSlide(_Theme.SelectSlideGameMode, _PartyModeId);
|
|
if (_Theme.SelectSlideAudioMode.HasValue)
|
|
{
|
|
_SelectSlideAudioMode = new CSelectSlide(_Theme.SelectSlideAudioMode.Value, _PartyModeId);
|
|
}
|
|
|
|
_AddStatic(_StaticPlaylistFooter);
|
|
_AddStatic(_StaticPlaylistHeader);
|
|
_AddButton(_ButtonPlaylistName);
|
|
_AddButton(_ButtonPlaylistClose);
|
|
_AddButton(_ButtonPlaylistDelete);
|
|
_AddButton(_ButtonPlaylistSave);
|
|
_AddButton(_ButtonPlaylistSing);
|
|
_AddButton(_ButtonPlaylistList);
|
|
|
|
Visible = false;
|
|
Selected = false;
|
|
ThemeLoaded = true;
|
|
}
|
|
|
|
private void _ReadSubThemeElements()
|
|
{
|
|
_Theme.Text1 = (SThemeText)_Text1.GetTheme();
|
|
_Theme.StaticPlaylistFooter = (SThemeStatic)_StaticPlaylistFooter.GetTheme();
|
|
_Theme.StaticPlaylistHeader = (SThemeStatic)_StaticPlaylistHeader.GetTheme();
|
|
_Theme.ButtonPlaylistName = (SThemeButton)_ButtonPlaylistName.GetTheme();
|
|
_Theme.ButtonPlaylistSing = (SThemeButton)_ButtonPlaylistSing.GetTheme();
|
|
_Theme.ButtonPlaylistClose = (SThemeButton)_ButtonPlaylistClose.GetTheme();
|
|
_Theme.ButtonPlaylistSave = (SThemeButton)_ButtonPlaylistSave.GetTheme();
|
|
_Theme.ButtonPlaylistDelete = (SThemeButton)_ButtonPlaylistDelete.GetTheme();
|
|
_Theme.ButtonPlaylistList = (SThemeButton)_ButtonPlaylistList.GetTheme();
|
|
}
|
|
|
|
public void UpdateGame()
|
|
{
|
|
if (_PlaylistElements.Count <= 0)
|
|
{
|
|
LoadPlaylist(0);
|
|
}
|
|
|
|
for (var i = 0; i < _PlaylistElements.Count; i++)
|
|
{
|
|
if (i == _CurrentPlaylistElement && _Selected)
|
|
{
|
|
_PlaylistElements[i].Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackgroundSelected, _PartyModeId);
|
|
_PlaylistElements[i].Background.Color = _BackgroundSelColor;
|
|
}
|
|
else
|
|
{
|
|
_PlaylistElements[i].Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackground, _PartyModeId);
|
|
_PlaylistElements[i].Background.Color = _BackgroundColor;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void Draw()
|
|
{
|
|
base.Draw();
|
|
|
|
if (_ChangeOrderElement != null)
|
|
{
|
|
_ChangeOrderElement.Draw();
|
|
}
|
|
}
|
|
|
|
public bool IsMouseOver(SMouseEvent mouseEvent)
|
|
{
|
|
return CHelper.IsInBounds(_CompleteRect, mouseEvent);
|
|
}
|
|
|
|
public void UnloadSkin()
|
|
{
|
|
_Text1.UnloadSkin();
|
|
_ButtonPlaylistClose.UnloadSkin();
|
|
_ButtonPlaylistDelete.UnloadSkin();
|
|
_ButtonPlaylistName.UnloadSkin();
|
|
_ButtonPlaylistSave.UnloadSkin();
|
|
_ButtonPlaylistSing.UnloadSkin();
|
|
_ButtonPlaylistList.UnloadSkin();
|
|
|
|
_StaticPlaylistFooter.UnloadSkin();
|
|
_StaticPlaylistHeader.UnloadSkin();
|
|
|
|
_SelectSlideGameMode.UnloadSkin();
|
|
_SelectSlideAudioMode?.UnloadSkin();
|
|
_ClearElements();
|
|
}
|
|
|
|
public void LoadSkin()
|
|
{
|
|
_Theme.ColorBackground.Get(_PartyModeId, out _BackgroundColor);
|
|
_Theme.SelColorBackground.Get(_PartyModeId, out _BackgroundSelColor);
|
|
|
|
MaxRect = _Theme.Rect;
|
|
|
|
_Text1.LoadSkin();
|
|
_ButtonPlaylistClose.LoadSkin();
|
|
_ButtonPlaylistDelete.LoadSkin();
|
|
_ButtonPlaylistName.LoadSkin();
|
|
_ButtonPlaylistSave.LoadSkin();
|
|
_ButtonPlaylistSing.LoadSkin();
|
|
_ButtonPlaylistList.LoadSkin();
|
|
|
|
_StaticPlaylistFooter.LoadSkin();
|
|
_StaticPlaylistHeader.LoadSkin();
|
|
|
|
_SelectSlideGameMode.LoadSkin();
|
|
_SelectSlideAudioMode?.LoadSkin();
|
|
|
|
_UpdateRect();
|
|
|
|
_PrepareList();
|
|
}
|
|
|
|
public void ReloadSkin()
|
|
{
|
|
UnloadSkin();
|
|
LoadSkin();
|
|
}
|
|
|
|
public override bool HandleInput(SKeyEvent keyEvent)
|
|
{
|
|
if (!Selected)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
//Active EditMode ignores other input!
|
|
if (_EditMode == EEditMode.PlaylistName)
|
|
{
|
|
if (keyEvent.KeyPressed && !Char.IsControl(keyEvent.Unicode))
|
|
{
|
|
_ButtonPlaylistName.Text.Text = _ButtonPlaylistName.Text.Text + keyEvent.Unicode;
|
|
}
|
|
else
|
|
{
|
|
switch (keyEvent.Key)
|
|
{
|
|
case Keys.Enter:
|
|
CBase.Playlist.SetName(ActivePlaylistId, _ButtonPlaylistName.Text.Text);
|
|
CBase.Playlist.Save(ActivePlaylistId);
|
|
_EditMode = EEditMode.None;
|
|
_ButtonPlaylistName.EditMode = false;
|
|
break;
|
|
case Keys.Escape:
|
|
_ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistId);
|
|
_EditMode = EEditMode.None;
|
|
_ButtonPlaylistName.EditMode = false;
|
|
break;
|
|
case Keys.Delete:
|
|
case Keys.Back:
|
|
if (!string.IsNullOrEmpty(_ButtonPlaylistName.Text.Text))
|
|
{
|
|
_ButtonPlaylistName.Text.Text = _ButtonPlaylistName.Text.Text.Remove(_ButtonPlaylistName.Text.Text.Length - 1);
|
|
}
|
|
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
if (_CurrentPlaylistElement == -1 || _PlaylistElementContents.Count == 0)
|
|
{
|
|
//no song is selected
|
|
var handled = base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
|
|
if (_CurrentPlaylistElement != -1 || handled)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
else if (_CurrentPlaylistElement != -1)
|
|
{
|
|
//a song is selected
|
|
var scrollLimit = _PlaylistElements.Count / 2;
|
|
|
|
//special actions if a song is selected
|
|
switch (keyEvent.Key)
|
|
{
|
|
case Keys.Up:
|
|
if (keyEvent.ModShift)
|
|
{
|
|
_SelectElement(_PlaylistElements[0].SelectSlide);
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
else if (_IsAudioSlideSelected(_CurrentPlaylistElement))
|
|
{
|
|
_SelectElement(_PlaylistElements[_CurrentPlaylistElement].SelectSlide);
|
|
}
|
|
else if (_CurrentPlaylistElement > scrollLimit || _PlaylistElementContents.Count == 0)
|
|
{
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
else if (_CurrentPlaylistElement <= scrollLimit)
|
|
{
|
|
if (_Offset > 0)
|
|
{
|
|
_Offset--;
|
|
_Update();
|
|
_SelectLastSlide(_CurrentPlaylistElement);
|
|
}
|
|
else
|
|
{
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Down:
|
|
if (keyEvent.ModShift)
|
|
{
|
|
for (var i = _PlaylistElements.Count - 1; i >= 0; i--)
|
|
{
|
|
if (_PlaylistElements[i].SelectSlide.Visible)
|
|
{
|
|
_SelectElement(_PlaylistElements[0].SelectSlide);
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
}
|
|
}
|
|
else if (_IsAudioSlideVisible(_CurrentPlaylistElement) && !_IsAudioSlideSelected(_CurrentPlaylistElement))
|
|
{
|
|
_SelectElement(_PlaylistElements[_CurrentPlaylistElement].SelectSlideAudio);
|
|
}
|
|
else if (_CurrentPlaylistElement >= scrollLimit)
|
|
{
|
|
if (_Offset < _PlaylistElementContents.Count - _PlaylistElements.Count)
|
|
{
|
|
_Offset++;
|
|
_Update();
|
|
_SelectElement(_PlaylistElements[_CurrentPlaylistElement].SelectSlide);
|
|
}
|
|
else
|
|
{
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
}
|
|
else if (_CurrentPlaylistElement < scrollLimit)
|
|
{
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Delete:
|
|
CBase.Playlist.DeleteSong(ActivePlaylistId, _PlaylistElements[_CurrentPlaylistElement].Content);
|
|
UpdatePlaylist();
|
|
|
|
if (_Offset > 0)
|
|
{
|
|
_Offset--;
|
|
}
|
|
|
|
_Update();
|
|
|
|
if (_PlaylistElementContents.Count - 1 < _CurrentPlaylistElement)
|
|
{
|
|
_CurrentPlaylistElement = _PlaylistElementContents.Count - 1;
|
|
}
|
|
|
|
if (_CurrentPlaylistElement != -1)
|
|
{
|
|
_SelectElement(_PlaylistElements[_CurrentPlaylistElement].SelectSlide);
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Back:
|
|
ClosePlaylist(); //really? or better global?
|
|
break;
|
|
|
|
case Keys.Enter:
|
|
_StartPlaylistSong(_CurrentPlaylistElement + _Offset);
|
|
break;
|
|
|
|
case Keys.Add: //move the selected song up
|
|
if (_PlaylistElementContents.Count > 1 && (_CurrentPlaylistElement > 0 || _Offset > 0))
|
|
{
|
|
CBase.Playlist.MoveSongUp(ActivePlaylistId, _CurrentPlaylistElement + _Offset);
|
|
UpdatePlaylist();
|
|
|
|
var key = new SKeyEvent { Key = Keys.Up };
|
|
|
|
if (_CurrentPlaylistElement > scrollLimit)
|
|
{
|
|
base.HandleInput(key);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
else if (_CurrentPlaylistElement <= scrollLimit)
|
|
{
|
|
if (_Offset > 0)
|
|
{
|
|
_Offset--;
|
|
_Update();
|
|
}
|
|
else
|
|
{
|
|
base.HandleInput(key);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Subtract: //move the selected song down
|
|
if (_PlaylistElementContents.Count > 1 && _CurrentPlaylistElement + _Offset < _PlaylistElementContents.Count - 1)
|
|
{
|
|
CBase.Playlist.MoveSongDown(ActivePlaylistId, _CurrentPlaylistElement + _Offset);
|
|
UpdatePlaylist();
|
|
|
|
var key = new SKeyEvent { Key = Keys.Down };
|
|
|
|
if (_CurrentPlaylistElement >= scrollLimit)
|
|
{
|
|
if (_Offset < _PlaylistElementContents.Count - _PlaylistElements.Count)
|
|
{
|
|
_Offset++;
|
|
_Update();
|
|
}
|
|
else
|
|
{
|
|
base.HandleInput(key);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
}
|
|
else if (_CurrentPlaylistElement < scrollLimit)
|
|
{
|
|
base.HandleInput(key);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.PageUp: //scroll up
|
|
if (_PlaylistElementContents.Count > 0)
|
|
{
|
|
_Offset -= _PlaylistElements.Count;
|
|
|
|
if (_Offset < 0)
|
|
{
|
|
_Offset = 0;
|
|
}
|
|
|
|
_Update();
|
|
_CurrentPlaylistElement = 0;
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.PageDown: //scroll down
|
|
if (_PlaylistElementContents.Count > 0)
|
|
{
|
|
_Offset += _PlaylistElements.Count;
|
|
|
|
if (_Offset > _PlaylistElementContents.Count - _PlaylistElements.Count)
|
|
{
|
|
_Offset = _PlaylistElementContents.Count - _PlaylistElements.Count;
|
|
}
|
|
|
|
if (_Offset < 0)
|
|
{
|
|
_Offset = 0;
|
|
}
|
|
|
|
_Update();
|
|
|
|
for (var i = _PlaylistElements.Count - 1; i >= 0; i--)
|
|
{
|
|
if (_PlaylistElements[i].SelectSlide.Visible)
|
|
{
|
|
_CurrentPlaylistElement = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Left:
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
|
|
if (_CurrentPlaylistElement != -1)
|
|
{
|
|
_ApplySelection(_CurrentPlaylistElement);
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Right:
|
|
base.HandleInput(keyEvent);
|
|
_CurrentPlaylistElement = _GetSelectedElementNr();
|
|
|
|
if (_CurrentPlaylistElement != -1)
|
|
{
|
|
_ApplySelection(_CurrentPlaylistElement);
|
|
}
|
|
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
//default actions
|
|
switch (keyEvent.Key)
|
|
{
|
|
case Keys.Back:
|
|
if (_ButtonPlaylistName.Selected)
|
|
{
|
|
_EditMode = EEditMode.PlaylistName;
|
|
_ButtonPlaylistName.EditMode = true;
|
|
_ChangeOrderElement = null;
|
|
}
|
|
else
|
|
{
|
|
ClosePlaylist();
|
|
}
|
|
|
|
break;
|
|
|
|
case Keys.Enter:
|
|
if (_ButtonPlaylistClose.Selected)
|
|
{
|
|
ClosePlaylist();
|
|
}
|
|
else if (_ButtonPlaylistSing.Selected)
|
|
{
|
|
_StartPlaylistSongs();
|
|
}
|
|
else if (_ButtonPlaylistSave.Selected)
|
|
{
|
|
CBase.Playlist.Save(ActivePlaylistId);
|
|
}
|
|
else if (isButtonPlaylistListSelected())
|
|
{
|
|
return false; // Currently CScreenSong do this event!
|
|
}
|
|
else if (_ButtonPlaylistDelete.Selected)
|
|
{
|
|
CBase.Playlist.Delete(ActivePlaylistId);
|
|
ClosePlaylist();
|
|
}
|
|
else if (_ButtonPlaylistName.Selected)
|
|
{
|
|
_ChangeOrderElement = null;
|
|
if (_EditMode != EEditMode.PlaylistName)
|
|
{
|
|
_EditMode = EEditMode.PlaylistName;
|
|
_ButtonPlaylistName.EditMode = true;
|
|
}
|
|
else
|
|
{
|
|
_EditMode = EEditMode.None;
|
|
_ButtonPlaylistName.EditMode = false;
|
|
}
|
|
}
|
|
|
|
break;
|
|
case Keys.PageDown:
|
|
_SetSelectionToLastEntry();
|
|
break;
|
|
case Keys.PageUp:
|
|
_SetSelectionToFirstEntry();
|
|
break;
|
|
default:
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public bool isButtonPlaylistListSelected()
|
|
{
|
|
return _ButtonPlaylistList.Selected;
|
|
}
|
|
|
|
private void _SetSelectionToLastEntry()
|
|
{
|
|
if (_PlaylistElementContents.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var off = _PlaylistElementContents.Count - _PlaylistElements.Count;
|
|
_Offset = off >= 0 ? off : 0;
|
|
|
|
_Update();
|
|
|
|
for (var i = _PlaylistElements.Count - 1; i >= 0; i--)
|
|
{
|
|
if (_PlaylistElements[i].SelectSlide.Visible)
|
|
{
|
|
_CurrentPlaylistElement = i;
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void _SetSelectionToFirstEntry()
|
|
{
|
|
if (_PlaylistElementContents.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
_Offset = 0;
|
|
_Update();
|
|
|
|
_CurrentPlaylistElement = 0;
|
|
}
|
|
|
|
private int _GetSelectedElementNr()
|
|
{
|
|
for (var i = 0; i < _PlaylistElements.Count; i++)
|
|
{
|
|
if (_PlaylistElements[i].SelectSlide.Selected || _IsAudioSlideSelected(i))
|
|
{
|
|
return i;
|
|
}
|
|
}
|
|
|
|
return -1;
|
|
}
|
|
|
|
private bool _IsAudioSlideVisible(int element)
|
|
{
|
|
return element >= 0 && element < _PlaylistElements.Count && _PlaylistElements[element].SelectSlideAudio != null && _PlaylistElements[element].SelectSlideAudio.Visible;
|
|
}
|
|
|
|
private bool _IsAudioSlideSelected(int element)
|
|
{
|
|
return element >= 0 && element < _PlaylistElements.Count && _PlaylistElements[element].SelectSlideAudio != null && _PlaylistElements[element].SelectSlideAudio.Selected;
|
|
}
|
|
|
|
private void _SelectLastSlide(int element)
|
|
{
|
|
_SelectElement(_IsAudioSlideVisible(element) ? _PlaylistElements[element].SelectSlideAudio : _PlaylistElements[element].SelectSlide);
|
|
}
|
|
|
|
private void _ApplySelection(int element)
|
|
{
|
|
var playlistSong = CBase.Playlist.GetSong(ActivePlaylistId, element + _Offset);
|
|
playlistSong.GameMode = _PlaylistElementContents[element + _Offset].Modes[_PlaylistElements[element].SelectSlide.Selection];
|
|
if (_IsAudioSlideVisible(element))
|
|
{
|
|
playlistSong.AudioMode = (EAudioMode)_PlaylistElements[element].SelectSlideAudio.SelectedTag;
|
|
}
|
|
|
|
UpdatePlaylist();
|
|
}
|
|
|
|
public void ScrollToBottom()
|
|
{
|
|
if (_PlaylistElementContents.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
var off = _PlaylistElementContents.Count - _PlaylistElements.Count;
|
|
_Offset = off >= 0 ? off : 0;
|
|
|
|
_Update();
|
|
}
|
|
|
|
public override bool HandleMouse(SMouseEvent mouseEvent)
|
|
{
|
|
base.HandleMouse(mouseEvent);
|
|
|
|
if (CHelper.IsInBounds(_CompleteRect, mouseEvent) && Visible)
|
|
{
|
|
//Scroll
|
|
if (mouseEvent.Wheel > 0)
|
|
{
|
|
if (_PlaylistElements.Count + _Offset + mouseEvent.Wheel <= _PlaylistElementContents.Count)
|
|
{
|
|
_Offset += mouseEvent.Wheel;
|
|
_Update();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
if (mouseEvent.Wheel < 0)
|
|
{
|
|
if (_Offset + mouseEvent.Wheel >= 0)
|
|
{
|
|
_Offset += mouseEvent.Wheel;
|
|
_Update();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
var hoverSet = false;
|
|
for (var i = 0; i < _PlaylistElements.Count; i++)
|
|
{
|
|
//Hover for playlist-element
|
|
if (_PlaylistElementContents.Count - 1 >= i && CHelper.IsInBounds(_PlaylistElements[i].Background.Rect, mouseEvent))
|
|
{
|
|
hoverSet = true;
|
|
_CurrentPlaylistElement = i;
|
|
_SelectElement(_IsAudioSlideVisible(i) && CHelper.IsInBounds(_PlaylistElements[i].SelectSlideAudio.Rect, mouseEvent)
|
|
? _PlaylistElements[i].SelectSlideAudio
|
|
: _PlaylistElements[i].SelectSlide);
|
|
ProcessMouseMove(mouseEvent.X, mouseEvent.Y);
|
|
}
|
|
|
|
//Delete Entry with RB
|
|
if (CHelper.IsInBounds(_PlaylistElements[i].Background.Rect, mouseEvent) && mouseEvent.RB && _PlaylistElements[i].Content != -1)
|
|
{
|
|
CBase.Playlist.DeleteSong(ActivePlaylistId, _PlaylistElements[i].Content);
|
|
UpdatePlaylist();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
if (!hoverSet)
|
|
{
|
|
_CurrentPlaylistElement = -1;
|
|
}
|
|
|
|
switch (_EditMode)
|
|
{
|
|
//Normal mode
|
|
case EEditMode.None:
|
|
|
|
//LB actions
|
|
if (mouseEvent.LB)
|
|
{
|
|
if (isButtonPlaylistListSelected())
|
|
{
|
|
return false; // Currently CScreenSong do this event!
|
|
}
|
|
|
|
if (_CurrentPlaylistElement != -1)
|
|
{
|
|
_ApplySelection(_CurrentPlaylistElement);
|
|
}
|
|
|
|
if (_ButtonPlaylistClose.Selected)
|
|
{
|
|
ClosePlaylist();
|
|
return true;
|
|
}
|
|
|
|
if (_ButtonPlaylistSing.Selected)
|
|
{
|
|
_StartPlaylistSongs();
|
|
return true;
|
|
}
|
|
|
|
if (_ButtonPlaylistSave.Selected)
|
|
{
|
|
CBase.Playlist.Save(ActivePlaylistId);
|
|
return true;
|
|
}
|
|
|
|
if (_ButtonPlaylistDelete.Selected)
|
|
{
|
|
CBase.Playlist.Delete(ActivePlaylistId);
|
|
ClosePlaylist();
|
|
return true;
|
|
}
|
|
|
|
if (_ButtonPlaylistName.Selected)
|
|
{
|
|
_EditMode = EEditMode.PlaylistName;
|
|
_ButtonPlaylistName.EditMode = true;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
//Start selected song with double click
|
|
if (mouseEvent.LD && _CurrentPlaylistElement != -1)
|
|
{
|
|
_StartPlaylistSong(_CurrentPlaylistElement + _Offset);
|
|
}
|
|
|
|
//Change order with holding LB
|
|
if (mouseEvent.LBH && _CurrentPlaylistElement != -1 && _PlaylistElementContents.Count > 0 && DragAndDropSongId == -1)
|
|
{
|
|
_ChangeOrderSource = _CurrentPlaylistElement + _Offset;
|
|
|
|
//Update of Drag/Drop-Texture
|
|
if (_ChangeOrderSource >= _PlaylistElementContents.Count)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
_ChangeOrderElement = new CPlaylistElement(_PlaylistElements[_CurrentPlaylistElement])
|
|
{
|
|
Background = { Z = CBase.Settings.GetZNear() },
|
|
Cover = { Z = CBase.Settings.GetZNear() },
|
|
SelectSlide = { Z = CBase.Settings.GetZNear() },
|
|
Text1 = { Z = CBase.Settings.GetZNear() }
|
|
};
|
|
|
|
if (_ChangeOrderElement.SelectSlideAudio != null)
|
|
{
|
|
_ChangeOrderElement.SelectSlideAudio.Z = CBase.Settings.GetZNear();
|
|
}
|
|
|
|
_ChangeOrderElement.Background.Texture = CBase.Themes.GetSkinTexture(_Theme.SkinBackground, _PartyModeId);
|
|
_ChangeOrderElement.Background.Color = _BackgroundColor;
|
|
|
|
_OldMousePosX = mouseEvent.X;
|
|
_OldMousePosY = mouseEvent.Y;
|
|
|
|
_EditMode = EEditMode.ChangeOrder;
|
|
}
|
|
|
|
if (!mouseEvent.LBH && DragAndDropSongId != -1)
|
|
{
|
|
var song = CBase.Songs.GetSongById(DragAndDropSongId);
|
|
|
|
if (song != null)
|
|
{
|
|
var gm = EGameMode.TR_GAMEMODE_NORMAL;
|
|
if (song.IsDuet)
|
|
{
|
|
gm = EGameMode.TR_GAMEMODE_DUET;
|
|
}
|
|
|
|
if (_CurrentPlaylistElement != -1)
|
|
{
|
|
CBase.Playlist.InsertSong(ActivePlaylistId, _CurrentPlaylistElement + _Offset, DragAndDropSongId, gm);
|
|
UpdatePlaylist();
|
|
}
|
|
else
|
|
{
|
|
if (mouseEvent.Y < _PlaylistElements[0].Background.Rect.Y && _Offset == 0)
|
|
{
|
|
CBase.Playlist.InsertSong(ActivePlaylistId, 0, DragAndDropSongId, gm);
|
|
UpdatePlaylist();
|
|
}
|
|
else
|
|
{
|
|
if (_PlaylistElements.Count + _Offset >= _PlaylistElementContents.Count)
|
|
{
|
|
var min = 0f;
|
|
for (var i = _PlaylistElements.Count - 1; i >= 0; i--)
|
|
{
|
|
if (_PlaylistElements[i].SelectSlide.Visible)
|
|
{
|
|
min = _PlaylistElements[i].SelectSlide.Rect.Y + _PlaylistElements[i].SelectSlide.Rect.H;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (mouseEvent.Y > min)
|
|
{
|
|
CBase.Playlist.AddSong(ActivePlaylistId, DragAndDropSongId, gm);
|
|
UpdatePlaylist();
|
|
ScrollToBottom();
|
|
}
|
|
}
|
|
}
|
|
|
|
DragAndDropSongId = -1;
|
|
UpdatePlaylist();
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case EEditMode.PlaylistName:
|
|
_SelectElement(_ButtonPlaylistName);
|
|
_CurrentPlaylistElement = -1;
|
|
if (mouseEvent.LB)
|
|
{
|
|
if (_ButtonPlaylistName.Selected)
|
|
{
|
|
CBase.Playlist.SetName(ActivePlaylistId, _ButtonPlaylistName.Text.Text);
|
|
CBase.Playlist.Save(ActivePlaylistId);
|
|
_EditMode = EEditMode.None;
|
|
return true;
|
|
}
|
|
}
|
|
else if (mouseEvent.RB)
|
|
{
|
|
if (_ButtonPlaylistName.Selected)
|
|
{
|
|
_ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistId);
|
|
_EditMode = EEditMode.None;
|
|
_ButtonPlaylistName.EditMode = false;
|
|
return true;
|
|
}
|
|
}
|
|
|
|
break;
|
|
|
|
case EEditMode.ChangeOrder:
|
|
//Actions according to playlist-element
|
|
|
|
//Update coords for Drag/Drop-Texture
|
|
_ChangeOrderElement.MouseMove(mouseEvent.X, mouseEvent.Y, _OldMousePosX, _OldMousePosY);
|
|
_OldMousePosX = mouseEvent.X;
|
|
_OldMousePosY = mouseEvent.Y;
|
|
|
|
if (!mouseEvent.LBH)
|
|
{
|
|
if (_CurrentPlaylistElement != -1 && _CurrentPlaylistElement + _Offset != _ChangeOrderSource)
|
|
{
|
|
CBase.Playlist.MoveSong(ActivePlaylistId, _ChangeOrderSource, _CurrentPlaylistElement + _Offset);
|
|
UpdatePlaylist();
|
|
}
|
|
else if (_CurrentPlaylistElement == -1)
|
|
{
|
|
if (mouseEvent.Y < _PlaylistElements[0].Background.Rect.Y && _Offset == 0)
|
|
{
|
|
CBase.Playlist.MoveSong(ActivePlaylistId, _ChangeOrderSource, 0);
|
|
}
|
|
else
|
|
{
|
|
if (_PlaylistElements.Count + _Offset >= _PlaylistElementContents.Count)
|
|
{
|
|
var min = 0f;
|
|
for (var i = _PlaylistElements.Count - 1; i >= 0; i--)
|
|
{
|
|
if (_PlaylistElements[i].SelectSlide.Visible)
|
|
{
|
|
min = _PlaylistElements[i].SelectSlide.Rect.Y + _PlaylistElements[i].SelectSlide.Rect.H;
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (mouseEvent.Y > min)
|
|
{
|
|
CBase.Playlist.MoveSong(ActivePlaylistId, _ChangeOrderSource, _PlaylistElementContents.Count - 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
UpdatePlaylist();
|
|
}
|
|
|
|
_EditMode = EEditMode.None;
|
|
_ChangeOrderElement = null;
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public bool isPlaylistNameEditMode()
|
|
{
|
|
return _EditMode == EEditMode.PlaylistName;
|
|
}
|
|
|
|
private void _PrepareList()
|
|
{
|
|
_PlaylistElements.Clear();
|
|
|
|
for (var i = 0; i < Math.Floor(_Theme.Rect.H / _Theme.EntryHeight); i++)
|
|
{
|
|
var en = new CPlaylistElement
|
|
{
|
|
Background = new CStatic(_PartyModeId, _Theme.SkinBackground, _BackgroundColor,
|
|
new SRectF(_Theme.Rect.X, _Theme.Rect.Y + i * _Theme.EntryHeight, _Theme.Rect.W, _Theme.EntryHeight, _Theme.Rect.Z)),
|
|
Cover = new CStatic(_Theme.StaticCover, _PartyModeId)
|
|
};
|
|
|
|
en.Cover.LoadSkin();
|
|
en.Cover.Y += _Theme.Rect.Y + i * _Theme.EntryHeight;
|
|
en.Cover.X += _Theme.Rect.X;
|
|
|
|
en.Text1 = new CText(_Text1);
|
|
en.Text1.X += _Theme.Rect.X;
|
|
en.Text1.Y += _Theme.Rect.Y + i * _Theme.EntryHeight;
|
|
|
|
en.SelectSlide = new CSelectSlide(_SelectSlideGameMode);
|
|
en.SelectSlide.LoadSkin();
|
|
en.SelectSlide.X += _Theme.Rect.X;
|
|
en.SelectSlide.Y += _Theme.Rect.Y + i * _Theme.EntryHeight;
|
|
|
|
if (_SelectSlideAudioMode != null)
|
|
{
|
|
en.SelectSlideAudio = new CSelectSlide(_SelectSlideAudioMode);
|
|
en.SelectSlideAudio.LoadSkin();
|
|
en.SelectSlideAudio.X += _Theme.Rect.X;
|
|
en.SelectSlideAudio.Y += _Theme.Rect.Y + i * _Theme.EntryHeight;
|
|
}
|
|
|
|
en.Content = -1;
|
|
|
|
_PlaylistElements.Add(en);
|
|
_AddSelectSlide(en.SelectSlide);
|
|
if (en.SelectSlideAudio != null)
|
|
{
|
|
_AddSelectSlide(en.SelectSlideAudio);
|
|
}
|
|
|
|
_AddText(en.Text1);
|
|
_AddStatic(en.Background);
|
|
_AddStatic(en.Cover);
|
|
}
|
|
}
|
|
|
|
public bool LoadPlaylist(int playlistId)
|
|
{
|
|
if (!CBase.Playlist.Exists(playlistId))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
ActivePlaylistId = playlistId;
|
|
_ButtonPlaylistName.Text.Text = CBase.Playlist.GetName(ActivePlaylistId);
|
|
_PlaylistElementContents.Clear();
|
|
for (var i = 0; i < CBase.Playlist.GetSongCount(ActivePlaylistId); i++)
|
|
{
|
|
var pec = new CPlaylistElementContent
|
|
{
|
|
SongId = CBase.Playlist.GetSong(ActivePlaylistId, i).SongId,
|
|
Modes = CBase.Songs.GetSongById(CBase.Playlist.GetSong(ActivePlaylistId, i).SongId).AvailableGameModes,
|
|
Mode = CBase.Playlist.GetSong(ActivePlaylistId, i).GameMode,
|
|
AudioMode = CBase.Playlist.GetSong(ActivePlaylistId, i).AudioMode
|
|
};
|
|
_PlaylistElementContents.Add(pec);
|
|
}
|
|
|
|
_SetSelectionToFirstEntry();
|
|
_Update();
|
|
return true;
|
|
}
|
|
|
|
public void UpdatePlaylist()
|
|
{
|
|
_PlaylistElementContents.Clear();
|
|
for (var i = 0; i < CBase.Playlist.GetSongCount(ActivePlaylistId); i++)
|
|
{
|
|
var pec = new CPlaylistElementContent { SongId = CBase.Playlist.GetSong(ActivePlaylistId, i).SongId };
|
|
pec.Modes = CBase.Songs.GetSongById(pec.SongId).AvailableGameModes;
|
|
pec.Mode = CBase.Playlist.GetSong(ActivePlaylistId, i).GameMode;
|
|
pec.AudioMode = CBase.Playlist.GetSong(ActivePlaylistId, i).AudioMode;
|
|
_PlaylistElementContents.Add(pec);
|
|
}
|
|
|
|
_Update();
|
|
}
|
|
|
|
public void ClosePlaylist()
|
|
{
|
|
Visible = false;
|
|
Selected = false;
|
|
ActivePlaylistId = -1;
|
|
}
|
|
|
|
private void _StartPlaylistSongs()
|
|
{
|
|
//TODO: What is if someone uses that in PartyMode?
|
|
CBase.Game.Reset();
|
|
CBase.Game.ClearSongs();
|
|
|
|
if (CBase.Playlist.Exists(ActivePlaylistId))
|
|
{
|
|
for (var i = 0; i < CBase.Playlist.GetSongCount(ActivePlaylistId); i++)
|
|
{
|
|
CBase.Game.AddSong(CBase.Playlist.GetSong(ActivePlaylistId, i).SongId, CBase.Playlist.GetSong(ActivePlaylistId, i).GameMode, CBase.Playlist.GetSong(ActivePlaylistId, i).AudioMode);
|
|
}
|
|
|
|
if (CBase.Game.GetNumSongs() > 0)
|
|
{
|
|
CBase.Graphics.FadeTo(EScreen.Names);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void _StartPlaylistSong(int selected)
|
|
{
|
|
CBase.Game.Reset();
|
|
CBase.Game.ClearSongs();
|
|
|
|
CBase.Game.AddSong(CBase.Playlist.GetSong(ActivePlaylistId, selected).SongId, CBase.Playlist.GetSong(ActivePlaylistId, selected).GameMode, CBase.Playlist.GetSong(ActivePlaylistId, selected).AudioMode);
|
|
|
|
if (CBase.Game.GetNumSongs() > 0)
|
|
{
|
|
CBase.Graphics.FadeTo(EScreen.Names);
|
|
}
|
|
}
|
|
|
|
private void _Update()
|
|
{
|
|
if (!CBase.Playlist.Exists(ActivePlaylistId))
|
|
{
|
|
return;
|
|
}
|
|
|
|
for (var i = 0; i < _PlaylistElements.Count; i++)
|
|
{
|
|
if (_Offset + i < _PlaylistElementContents.Count)
|
|
{
|
|
_PlaylistElements[i].Content = _Offset + i;
|
|
_PlaylistElements[i].Background.Visible = true;
|
|
_PlaylistElements[i].Cover.Visible = true;
|
|
_PlaylistElements[i].SelectSlide.Visible = true;
|
|
_PlaylistElements[i].Text1.Visible = true;
|
|
var pec = _PlaylistElementContents[_Offset + i];
|
|
var song = CBase.Songs.GetSongById(pec.SongId);
|
|
_PlaylistElements[i].Cover.Texture = song.CoverTextureSmall;
|
|
var t1 = CBase.Language.Translate(_Text1.Text).Replace("%a", song.Artist).Replace("%t", song.Title);
|
|
_PlaylistElements[i].Text1.Text = /*(Offset + i + 1) + ") " + */ t1; //TODO: Add text field for the number
|
|
_PlaylistElements[i].SelectSlide.Clear();
|
|
foreach (var gm in pec.Modes)
|
|
{
|
|
_PlaylistElements[i].SelectSlide.AddValue(Enum.GetName(typeof(EGameMode), gm), null, (int)gm);
|
|
}
|
|
|
|
_PlaylistElements[i].SelectSlide.SelectedTag = (int)pec.Mode;
|
|
_UpdateAudioSlide(i, song, pec.AudioMode);
|
|
}
|
|
else
|
|
{
|
|
_PlaylistElements[i].Background.Visible = false;
|
|
_PlaylistElements[i].Cover.Visible = false;
|
|
_PlaylistElements[i].SelectSlide.Visible = false;
|
|
if (_PlaylistElements[i].SelectSlideAudio != null)
|
|
{
|
|
_PlaylistElements[i].SelectSlideAudio.Visible = false;
|
|
}
|
|
|
|
_PlaylistElements[i].Text1.Visible = false;
|
|
_PlaylistElements[i].Content = -1;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void _UpdateAudioSlide(int element, CSong song, EAudioMode audioMode)
|
|
{
|
|
var audioSlide = _PlaylistElements[element].SelectSlideAudio;
|
|
if (audioSlide == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
audioSlide.Clear();
|
|
if (!song.HasInstrumental())
|
|
{
|
|
if (audioSlide.Selected)
|
|
{
|
|
_SelectElement(_PlaylistElements[element].SelectSlide);
|
|
}
|
|
|
|
audioSlide.Visible = false;
|
|
return;
|
|
}
|
|
|
|
audioSlide.AddValue("TR_AUDIOMODE_NORMAL", null, (int)EAudioMode.TR_AUDIOMODE_NORMAL);
|
|
audioSlide.AddValue("TR_AUDIOMODE_INSTRUMENTAL", null, (int)EAudioMode.TR_AUDIOMODE_INSTRUMENTAL);
|
|
if (song.HasVocals())
|
|
{
|
|
audioSlide.AddValue("TR_AUDIOMODE_VOCALS", null, (int)EAudioMode.TR_AUDIOMODE_VOCALS);
|
|
}
|
|
|
|
audioSlide.AddValue("TR_AUDIOMODE_KARAOKE", null, (int)EAudioMode.TR_AUDIOMODE_KARAOKE);
|
|
audioSlide.SelectedTag = (int)audioMode;
|
|
if (audioSlide.SelectedTag != (int)audioMode)
|
|
{
|
|
audioSlide.SelectedTag = (int)EAudioMode.TR_AUDIOMODE_NORMAL;
|
|
}
|
|
|
|
audioSlide.Visible = true;
|
|
}
|
|
|
|
public object GetTheme()
|
|
{
|
|
_ReadSubThemeElements();
|
|
return _Theme;
|
|
}
|
|
|
|
private void _UpdateRect()
|
|
{
|
|
//Check for highest x/y-coords
|
|
_CompleteRect = _Theme.Rect;
|
|
//ButtonPlaylistClose
|
|
if (_ButtonPlaylistClose.Rect.X < _CompleteRect.X)
|
|
{
|
|
_CompleteRect.X = _ButtonPlaylistClose.Rect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistClose.Rect.Y < _CompleteRect.Y)
|
|
{
|
|
_CompleteRect.Y = _ButtonPlaylistClose.Rect.Y;
|
|
}
|
|
|
|
if (_ButtonPlaylistClose.Rect.W + _ButtonPlaylistClose.Rect.X > _CompleteRect.W + _CompleteRect.X)
|
|
{
|
|
_CompleteRect.W = _ButtonPlaylistClose.Rect.W + _ButtonPlaylistClose.Rect.X - _CompleteRect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistClose.Rect.Y + _ButtonPlaylistClose.Rect.H > _CompleteRect.Y + _CompleteRect.H)
|
|
{
|
|
_CompleteRect.H = _ButtonPlaylistClose.Rect.H + _ButtonPlaylistClose.Rect.Y - _CompleteRect.Y;
|
|
}
|
|
|
|
//ButtonPlaylistName
|
|
if (_ButtonPlaylistName.Rect.X < _CompleteRect.X)
|
|
{
|
|
_CompleteRect.X = _ButtonPlaylistName.Rect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistName.Rect.Y < _CompleteRect.Y)
|
|
{
|
|
_CompleteRect.Y = _ButtonPlaylistName.Rect.Y;
|
|
}
|
|
|
|
if (_ButtonPlaylistName.Rect.W + _ButtonPlaylistName.Rect.X > _CompleteRect.W + _CompleteRect.X)
|
|
{
|
|
_CompleteRect.W = _ButtonPlaylistName.Rect.W + _ButtonPlaylistName.Rect.X - _CompleteRect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistName.Rect.Y + _ButtonPlaylistName.Rect.H > _CompleteRect.Y + _CompleteRect.H)
|
|
{
|
|
_CompleteRect.H = _ButtonPlaylistName.Rect.H + _ButtonPlaylistName.Rect.Y - _CompleteRect.Y;
|
|
}
|
|
|
|
//ButtonPlaylistSing
|
|
if (_ButtonPlaylistSing.Rect.X < _CompleteRect.X)
|
|
{
|
|
_CompleteRect.X = _ButtonPlaylistSing.Rect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistSing.Rect.Y < _CompleteRect.Y)
|
|
{
|
|
_CompleteRect.Y = _ButtonPlaylistSing.Rect.Y;
|
|
}
|
|
|
|
if (_ButtonPlaylistSing.Rect.W + _ButtonPlaylistSing.Rect.X > _CompleteRect.W + _CompleteRect.X)
|
|
{
|
|
_CompleteRect.W = _ButtonPlaylistSing.Rect.W + _ButtonPlaylistSing.Rect.X - _CompleteRect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistSing.Rect.Y + _ButtonPlaylistSing.Rect.H > _CompleteRect.Y + _CompleteRect.H)
|
|
{
|
|
_CompleteRect.H = _ButtonPlaylistSing.Rect.H + _ButtonPlaylistSing.Rect.Y - _CompleteRect.Y;
|
|
}
|
|
|
|
//ButtonPlaylistSave
|
|
if (_ButtonPlaylistSave.Rect.X < _CompleteRect.X)
|
|
{
|
|
_CompleteRect.X = _ButtonPlaylistSave.Rect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistSave.Rect.Y < _CompleteRect.Y)
|
|
{
|
|
_CompleteRect.Y = _ButtonPlaylistSave.Rect.Y;
|
|
}
|
|
|
|
if (_ButtonPlaylistSave.Rect.W + _ButtonPlaylistSave.Rect.X > _CompleteRect.W + _CompleteRect.X)
|
|
{
|
|
_CompleteRect.W = _ButtonPlaylistSave.Rect.W + _ButtonPlaylistSave.Rect.X - _CompleteRect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistSave.Rect.Y + _ButtonPlaylistSave.Rect.H > _CompleteRect.Y + _CompleteRect.H)
|
|
{
|
|
_CompleteRect.H = _ButtonPlaylistSave.Rect.H + _ButtonPlaylistSave.Rect.Y - _CompleteRect.Y;
|
|
}
|
|
|
|
//ButtonPlaylistDelete
|
|
if (_ButtonPlaylistDelete.Rect.X < _CompleteRect.X)
|
|
{
|
|
_CompleteRect.X = _ButtonPlaylistDelete.Rect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistDelete.Rect.Y < _CompleteRect.Y)
|
|
{
|
|
_CompleteRect.Y = _ButtonPlaylistDelete.Rect.Y;
|
|
}
|
|
|
|
if (_ButtonPlaylistDelete.Rect.W + _ButtonPlaylistDelete.Rect.X > _CompleteRect.W + _CompleteRect.X)
|
|
{
|
|
_CompleteRect.W = _ButtonPlaylistDelete.Rect.W + _ButtonPlaylistDelete.Rect.X - _CompleteRect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistDelete.Rect.Y + _ButtonPlaylistDelete.Rect.H > _CompleteRect.Y + _CompleteRect.H)
|
|
{
|
|
_CompleteRect.H = _ButtonPlaylistDelete.Rect.H + _ButtonPlaylistDelete.Rect.Y - _CompleteRect.Y;
|
|
}
|
|
|
|
//ButtonPlaylistList
|
|
if (_ButtonPlaylistList.Rect.X < _CompleteRect.X)
|
|
{
|
|
_CompleteRect.X = _ButtonPlaylistList.Rect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistList.Rect.Y < _CompleteRect.Y)
|
|
{
|
|
_CompleteRect.Y = _ButtonPlaylistList.Rect.Y;
|
|
}
|
|
|
|
if (_ButtonPlaylistList.Rect.W + _ButtonPlaylistList.Rect.X > _CompleteRect.W + _CompleteRect.X)
|
|
{
|
|
_CompleteRect.W = _ButtonPlaylistList.Rect.W + _ButtonPlaylistList.Rect.X - _CompleteRect.X;
|
|
}
|
|
|
|
if (_ButtonPlaylistList.Rect.Y + _ButtonPlaylistList.Rect.H > _CompleteRect.Y + _CompleteRect.H)
|
|
{
|
|
_CompleteRect.H = _ButtonPlaylistList.Rect.H + _ButtonPlaylistList.Rect.Y - _CompleteRect.Y;
|
|
}
|
|
}
|
|
|
|
#region ThemeEdit
|
|
public void MoveElement(int stepX, int stepY)
|
|
{
|
|
var rect = MaxRect;
|
|
rect.X += stepX;
|
|
rect.Y += stepY;
|
|
MaxRect = rect;
|
|
|
|
_Theme.Rect.X += stepX;
|
|
_Theme.Rect.Y += stepY;
|
|
}
|
|
|
|
public void ResizeElement(int stepW, int stepH)
|
|
{
|
|
var rect = MaxRect;
|
|
rect.W += stepW;
|
|
if (rect.W <= 0)
|
|
{
|
|
rect.W = 1;
|
|
}
|
|
|
|
rect.H += stepH;
|
|
if (rect.H <= 0)
|
|
{
|
|
rect.H = 1;
|
|
}
|
|
|
|
MaxRect = rect;
|
|
|
|
_Theme.Rect.W = Rect.W;
|
|
_Theme.Rect.H = Rect.H;
|
|
}
|
|
#endregion ThemeEdit
|
|
}
|
|
} |