236 lines
8.4 KiB
C#
236 lines
8.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
using Vocaluxe.Base;
|
|
using Vocaluxe.Lib.Draw;
|
|
using Vocaluxe.Menu;
|
|
using Vocaluxe.Lib.Song;
|
|
|
|
namespace Vocaluxe.Screens
|
|
{
|
|
class CPopupScreenPlayerControl : CMenu
|
|
{
|
|
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
|
const int ScreenVersion = 1;
|
|
|
|
private const string StaticBG = "StaticBG";
|
|
private const string StaticCover = "StaticCover";
|
|
|
|
private const string ButtonPrevious = "ButtonPrevious";
|
|
private const string ButtonPlay = "ButtonPlay";
|
|
private const string ButtonPause = "ButtonPause";
|
|
private const string ButtonNext = "ButtonNext";
|
|
private const string ButtonRepeat = "ButtonRepeat";
|
|
private const string ButtonShowVideo = "ButtonShowVideo";
|
|
private const string ButtonSing = "ButtonSing";
|
|
private const string ButtonToBackgroundVideo = "ButtonToBackgroundVideo";
|
|
|
|
private const string TextCurrentSong = "TextCurrentSong";
|
|
|
|
private bool _VideoPreview = false;
|
|
private bool _VideoBackground
|
|
{
|
|
get
|
|
{
|
|
return CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON;
|
|
}
|
|
set
|
|
{
|
|
if (CConfig.VideosToBackground == EOffOn.TR_CONFIG_ON)
|
|
{
|
|
CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF;
|
|
if (!_VideoPreview) //No videos are enabled so we should call ToggleVideo() to close
|
|
CBackgroundMusic.ToggleVideo();
|
|
}
|
|
else
|
|
{
|
|
CConfig.VideosToBackground = EOffOn.TR_CONFIG_ON;
|
|
CBackgroundMusic.VideoEnabled = true;
|
|
}
|
|
CConfig.SaveConfig();
|
|
}
|
|
}
|
|
|
|
public CPopupScreenPlayerControl()
|
|
{
|
|
Init();
|
|
}
|
|
|
|
protected override void Init()
|
|
{
|
|
base.Init();
|
|
|
|
_ThemeName = "PopupScreenPlayerControl";
|
|
_ScreenVersion = ScreenVersion;
|
|
|
|
_ThemeStatics = new string[] { StaticBG, StaticCover };
|
|
_ThemeTexts = new string[] { TextCurrentSong };
|
|
|
|
List<string> buttons = new List<string>();
|
|
buttons.Add(ButtonPlay);
|
|
buttons.Add(ButtonPause);
|
|
buttons.Add(ButtonPrevious);
|
|
buttons.Add(ButtonNext);
|
|
buttons.Add(ButtonRepeat);
|
|
buttons.Add(ButtonShowVideo);
|
|
buttons.Add(ButtonSing);
|
|
buttons.Add(ButtonToBackgroundVideo);
|
|
_ThemeButtons = buttons.ToArray();
|
|
}
|
|
|
|
public override void LoadTheme()
|
|
{
|
|
base.LoadTheme();
|
|
|
|
_ScreenArea = Statics[htStatics(StaticBG)].Rect;
|
|
}
|
|
|
|
public override bool HandleInput(KeyEvent KeyEvent)
|
|
{
|
|
base.HandleInput(KeyEvent);
|
|
if (KeyEvent.KeyPressed && !Char.IsControl(KeyEvent.Unicode))
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
switch (KeyEvent.Key)
|
|
{
|
|
case Keys.Escape:
|
|
case Keys.Back:
|
|
CGraphics.HidePopup(EPopupScreens.PopupPlayerControl);
|
|
return false;
|
|
|
|
case Keys.Enter:
|
|
if (Buttons[htButtons(ButtonNext)].Selected)
|
|
CBackgroundMusic.Next();
|
|
if (Buttons[htButtons(ButtonPrevious)].Selected)
|
|
CBackgroundMusic.Previous();
|
|
if (Buttons[htButtons(ButtonPlay)].Selected)
|
|
CBackgroundMusic.Play();
|
|
if (Buttons[htButtons(ButtonPause)].Selected)
|
|
CBackgroundMusic.Pause();
|
|
if (Buttons[htButtons(ButtonRepeat)].Selected)
|
|
CBackgroundMusic.Repeat();
|
|
if (Buttons[htButtons(ButtonShowVideo)].Selected)
|
|
TogglePreviewVideo();
|
|
if (Buttons[htButtons(ButtonSing)].Selected)
|
|
StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
|
|
if (Buttons[htButtons(ButtonToBackgroundVideo)].Selected)
|
|
ToggleBackgroundVideo();
|
|
break;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public override bool HandleMouse(MouseEvent MouseEvent)
|
|
{
|
|
base.HandleMouse(MouseEvent);
|
|
if (MouseEvent.LB && IsMouseOver(MouseEvent))
|
|
{
|
|
if (Buttons[htButtons(ButtonNext)].Selected)
|
|
CBackgroundMusic.Next();
|
|
if (Buttons[htButtons(ButtonPrevious)].Selected)
|
|
CBackgroundMusic.Previous();
|
|
if (Buttons[htButtons(ButtonPlay)].Selected)
|
|
CBackgroundMusic.Play();
|
|
if (Buttons[htButtons(ButtonPause)].Selected)
|
|
CBackgroundMusic.Pause();
|
|
if (Buttons[htButtons(ButtonRepeat)].Selected)
|
|
CBackgroundMusic.Repeat();
|
|
if (Buttons[htButtons(ButtonShowVideo)].Selected)
|
|
TogglePreviewVideo();
|
|
if (Buttons[htButtons(ButtonSing)].Selected)
|
|
StartSong(CBackgroundMusic.SongID, CBackgroundMusic.Duet);
|
|
if (Buttons[htButtons(ButtonToBackgroundVideo)].Selected)
|
|
ToggleBackgroundVideo();
|
|
} else if (MouseEvent.LB)
|
|
{
|
|
CGraphics.HidePopup(EPopupScreens.PopupPlayerControl);
|
|
return false;
|
|
} else if (MouseEvent.RB)
|
|
{
|
|
CGraphics.HidePopup(EPopupScreens.PopupPlayerControl);
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public override bool UpdateGame()
|
|
{
|
|
Statics[htStatics(StaticCover)].Visible = !_VideoPreview;
|
|
Buttons[htButtons(ButtonToBackgroundVideo)].Pressed = _VideoBackground;
|
|
Buttons[htButtons(ButtonShowVideo)].Pressed = _VideoPreview;
|
|
return true;
|
|
}
|
|
|
|
public override void OnShow()
|
|
{
|
|
base.OnShow();
|
|
}
|
|
|
|
public override bool Draw()
|
|
{
|
|
if (!_Active)
|
|
return false;
|
|
Statics[htStatics(StaticCover)].Texture = CBackgroundMusic.Cover;
|
|
if (CBackgroundMusic.VideoEnabled && CBackgroundMusic.SongHasVideo)
|
|
CDraw.DrawTexture(Statics[htStatics(StaticCover)], CBackgroundMusic.GetVideoTexture(), EAspect.Crop);
|
|
Buttons[htButtons(ButtonPause)].Visible = CBackgroundMusic.Playing;
|
|
Buttons[htButtons(ButtonPlay)].Visible = !CBackgroundMusic.Playing;
|
|
Texts[htTexts(TextCurrentSong)].Text = CBackgroundMusic.ArtistAndTitle;
|
|
if (CBackgroundMusic.VideoEnabled)
|
|
Buttons[htButtons(ButtonShowVideo)].SColor = CTheme.GetColor("ButtonSColor");
|
|
|
|
return base.Draw();
|
|
}
|
|
|
|
private void StartSong(int SongNr, bool Duet)
|
|
{
|
|
if (SongNr >= 0 && CSongs.SongsLoaded)
|
|
{
|
|
if (Duet)
|
|
CGame.SetGameMode(GameModes.EGameMode.Duet);
|
|
else
|
|
CGame.SetGameMode(GameModes.EGameMode.Normal);
|
|
|
|
CGame.Reset();
|
|
CGame.ClearSongs();
|
|
CGame.AddSong(SongNr);
|
|
|
|
CGraphics.FadeTo(EScreens.ScreenNames);
|
|
}
|
|
}
|
|
|
|
private void ToggleBackgroundVideo()
|
|
{
|
|
if (_VideoBackground)
|
|
{
|
|
CConfig.VideosToBackground = EOffOn.TR_CONFIG_OFF;
|
|
if (!_VideoPreview) //No videos are enabled so we should call ToggleVideo() to close
|
|
CBackgroundMusic.ToggleVideo();
|
|
}
|
|
else
|
|
{
|
|
CConfig.VideosToBackground = EOffOn.TR_CONFIG_ON;
|
|
CBackgroundMusic.VideoEnabled = true;
|
|
}
|
|
CConfig.SaveConfig();
|
|
}
|
|
|
|
private void TogglePreviewVideo()
|
|
{
|
|
_VideoPreview = !_VideoPreview;
|
|
if (!_VideoPreview && !_VideoBackground)
|
|
CBackgroundMusic.ToggleVideo();
|
|
else
|
|
CBackgroundMusic.VideoEnabled = true;
|
|
}
|
|
}
|
|
}
|