Merge pull request #464 from Vocaluxe/SongScreen-Highscore
Keyboard shortcut and button to show the highscores of the selected song
This commit is contained in:
5 files changed
+143
-57
No files matched your search
@@ -2,7 +2,7 @@
|
|||||||
<Screen xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
<Screen xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||||
<Informations>
|
<Informations>
|
||||||
<ScreenName>ScreenSong</ScreenName>
|
<ScreenName>ScreenSong</ScreenName>
|
||||||
<ScreenVersion>7</ScreenVersion>
|
<ScreenVersion>8</ScreenVersion>
|
||||||
</Informations>
|
</Informations>
|
||||||
<Backgrounds>
|
<Backgrounds>
|
||||||
<Background Name="Background1">
|
<Background Name="Background1">
|
||||||
@@ -788,6 +788,33 @@
|
|||||||
<Text>TR_SCREENSONG_BUTTON_STARTMEDLEY</Text>
|
<Text>TR_SCREENSONG_BUTTON_STARTMEDLEY</Text>
|
||||||
</Text>
|
</Text>
|
||||||
</Button>
|
</Button>
|
||||||
|
<Button Name="ButtonOptionsHighscore">
|
||||||
|
<Skin>SongSelectButton</Skin>
|
||||||
|
<SkinSelected>SongSelectButton</SkinSelected>
|
||||||
|
<Rect>
|
||||||
|
<X>40</X>
|
||||||
|
<Y>290</Y>
|
||||||
|
<W>360</W>
|
||||||
|
<H>40</H>
|
||||||
|
<Z>-2.11</Z>
|
||||||
|
</Rect>
|
||||||
|
<Color Name="ButtonColor" />
|
||||||
|
<SelColor Name="ButtonSelColor" />
|
||||||
|
<Text Name="Text">
|
||||||
|
<X>180</X>
|
||||||
|
<Y>7</Y>
|
||||||
|
<Z>0</Z>
|
||||||
|
<H>25</H>
|
||||||
|
<MaxW>350</MaxW>
|
||||||
|
<Color Name="ButtonTextColor" />
|
||||||
|
<SelColor Name="ButtonTextSelColor" />
|
||||||
|
<Align>Center</Align>
|
||||||
|
<ResizeAlign>Center</ResizeAlign>
|
||||||
|
<Style>Bold</Style>
|
||||||
|
<Font>Outline</Font>
|
||||||
|
<Text>TR_SCREENHIGHSCORE_HIGHSCORE</Text>
|
||||||
|
</Text>
|
||||||
|
</Button>
|
||||||
</Buttons>
|
</Buttons>
|
||||||
<SongMenus>
|
<SongMenus>
|
||||||
<SongMenu Name="SongMenu">
|
<SongMenu Name="SongMenu">
|
||||||
|
|||||||
@@ -316,56 +316,33 @@ namespace Vocaluxe.Base
|
|||||||
CSound.SetGlobalVolume(CConfig.PreviewMusicVolume);
|
CSound.SetGlobalVolume(CConfig.PreviewMusicVolume);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Change song position only if song is changed or near to end
|
||||||
bool songChanged = _CurPlayer.SongID != song.ID;
|
bool songChanged = _CurPlayer.SongID != song.ID;
|
||||||
|
if (!songChanged && _CurPlayer.Position + 30 < _CurPlayer.Length)
|
||||||
|
return;
|
||||||
|
|
||||||
_PreviewPlayer.Load(song);
|
_PreviewPlayer.Load(song);
|
||||||
|
|
||||||
|
lock (_PreviewStartHelperTaskLock)
|
||||||
//Change song position only if song is changed or near to end
|
|
||||||
if (songChanged || _CurPlayer.Position + 30 < _CurPlayer.Length || _PreviewStartHelperTask == null)
|
|
||||||
{
|
{
|
||||||
lock (_PreviewStartHelperTaskLock)
|
_PreviewStartHelperTask = new Task(() =>
|
||||||
{
|
{
|
||||||
_PreviewStartHelperTask = new Task(() =>
|
float length = _PreviewPlayer.Length;
|
||||||
{
|
if (length < 1)
|
||||||
float length = _PreviewPlayer.Length;
|
length = 30; // If length is unknow or invalid assume a length of 30s
|
||||||
if (length < 1)
|
|
||||||
length = 30; // If length is unknow or invalid assume a length of 30s
|
|
||||||
|
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
start = (song.Preview.Source == EDataSource.None) ? length / 4f : song.Preview.StartTime;
|
start = (song.Preview.Source == EDataSource.None) ? length / 4f : song.Preview.StartTime;
|
||||||
if (start > length - 5f)
|
if (start > length - 5f)
|
||||||
start = Math.Max(0f, Math.Min(length / 4f, length - 5f));
|
start = Math.Max(0f, Math.Min(length / 4f, length - 5f));
|
||||||
if (start >= 0.5f)
|
if (start >= 0.5f)
|
||||||
start -= 0.5f;
|
start -= 0.5f;
|
||||||
|
|
||||||
_PreviewPlayer.Position = start;
|
_PreviewPlayer.Position = start;
|
||||||
Play();
|
Play();
|
||||||
});
|
});
|
||||||
}
|
|
||||||
_CurPlayer = _PreviewPlayer;
|
|
||||||
}
|
}
|
||||||
else
|
_CurPlayer = _PreviewPlayer;
|
||||||
{
|
|
||||||
if (_PreviewStartHelperTask != null)
|
|
||||||
{
|
|
||||||
lock (_PreviewStartHelperTaskLock)
|
|
||||||
{
|
|
||||||
// Recheck the condition as it cloud have change before we got the lock
|
|
||||||
if (_PreviewStartHelperTask != null)
|
|
||||||
{
|
|
||||||
_PreviewStartHelperTask = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_PreviewPlayer.Position = _CurPlayer.Position;
|
|
||||||
_CurPlayer = _PreviewPlayer;
|
|
||||||
Play();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void StopPreview()
|
public static void StopPreview()
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ namespace Vocaluxe.Screens
|
|||||||
private int _Round;
|
private int _Round;
|
||||||
private int _Pos;
|
private int _Pos;
|
||||||
private bool _IsDuet;
|
private bool _IsDuet;
|
||||||
|
private bool _FromScreenSong = false;
|
||||||
|
|
||||||
public override EMusicType CurrentMusicType
|
public override EMusicType CurrentMusicType
|
||||||
{
|
{
|
||||||
@@ -113,11 +114,13 @@ namespace Vocaluxe.Screens
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case Keys.Down:
|
case Keys.Down:
|
||||||
_ChangePos(1);
|
if (!_FromScreenSong)
|
||||||
|
_ChangePos(1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Keys.Up:
|
case Keys.Up:
|
||||||
_ChangePos(-1);
|
if (!_FromScreenSong)
|
||||||
|
_ChangePos(-1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Keys.Left:
|
case Keys.Left:
|
||||||
@@ -234,13 +237,37 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
_Pos = 0;
|
_Pos = 0;
|
||||||
int rounds = CGame.NumRounds;
|
int rounds = CGame.NumRounds;
|
||||||
_Scores = new List<SDBScoreEntry>[rounds];
|
|
||||||
for (int round = 0; round < rounds; round++)
|
if (rounds == 0)
|
||||||
{
|
{
|
||||||
int songID = CGame.GetSong(round).ID;
|
_FromScreenSong = true;
|
||||||
EGameMode gameMode = CGame.GetGameMode(round);
|
_Round = (int)EGameMode.TR_GAMEMODE_NORMAL;
|
||||||
|
_Scores = new List<SDBScoreEntry>[4];
|
||||||
|
int songID = CScreenSong.getSelectedSongID();
|
||||||
EHighscoreStyle style = CBase.Config.GetHighscoreStyle();
|
EHighscoreStyle style = CBase.Config.GetHighscoreStyle();
|
||||||
_Scores[round] = CDataBase.LoadScore(songID, gameMode, style);
|
bool foundHighscoreEntries = false;
|
||||||
|
|
||||||
|
for (int gameModeNum = 0; gameModeNum < 4; gameModeNum++)
|
||||||
|
{
|
||||||
|
_Scores[gameModeNum] = CDataBase.LoadScore(songID, (EGameMode)gameModeNum, style);
|
||||||
|
if (!foundHighscoreEntries && _Scores[gameModeNum].Count > 0)
|
||||||
|
{
|
||||||
|
_Round = gameModeNum;
|
||||||
|
foundHighscoreEntries = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_FromScreenSong = false;
|
||||||
|
_Scores = new List<SDBScoreEntry>[rounds];
|
||||||
|
for (int round = 0; round < rounds; round++)
|
||||||
|
{
|
||||||
|
int songID = CGame.GetSong(round).ID;
|
||||||
|
EGameMode gameMode = CGame.GetGameMode(round);
|
||||||
|
EHighscoreStyle style = CBase.Config.GetHighscoreStyle();
|
||||||
|
_Scores[round] = CDataBase.LoadScore(songID, gameMode, style);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -248,15 +275,21 @@ namespace Vocaluxe.Screens
|
|||||||
{
|
{
|
||||||
_IsDuet = false;
|
_IsDuet = false;
|
||||||
CPoints points = CGame.GetPoints();
|
CPoints points = CGame.GetPoints();
|
||||||
CSong song = CGame.GetSong(_Round);
|
|
||||||
|
CSong song;
|
||||||
|
if (_FromScreenSong)
|
||||||
|
song = CSongs.GetSong(CScreenSong.getSelectedSongID());
|
||||||
|
else
|
||||||
|
song = CGame.GetSong(_Round);
|
||||||
|
|
||||||
if (song == null)
|
if (song == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
|
_Texts[_TextSongName].Text = song.Artist + " - " + song.Title;
|
||||||
if (points.NumRounds > 1)
|
if (points != null && !_FromScreenSong && points.NumRounds > 1)
|
||||||
_Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
|
_Texts[_TextSongName].Text += " (" + (_Round + 1) + "/" + points.NumRounds + ")";
|
||||||
|
|
||||||
switch (CGame.GetGameMode(_Round))
|
switch ((_FromScreenSong ? (EGameMode)_Round : CGame.GetGameMode(_Round)))
|
||||||
{
|
{
|
||||||
case EGameMode.TR_GAMEMODE_NORMAL:
|
case EGameMode.TR_GAMEMODE_NORMAL:
|
||||||
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
|
_Texts[_TextSongMode].Text = "TR_GAMEMODE_NORMAL";
|
||||||
@@ -296,9 +329,20 @@ namespace Vocaluxe.Screens
|
|||||||
|
|
||||||
private void _ChangeRound(int num)
|
private void _ChangeRound(int num)
|
||||||
{
|
{
|
||||||
CPoints points = CGame.GetPoints();
|
if (_FromScreenSong)
|
||||||
_Round += num;
|
{
|
||||||
_Round = _Round.Clamp(0, points.NumRounds - 1);
|
if (_Round == (int)EGameMode.TR_GAMEMODE_SHORTSONG)
|
||||||
|
_Round = (int)EGameMode.TR_GAMEMODE_NORMAL;
|
||||||
|
else
|
||||||
|
++_Round;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
CPoints points = CGame.GetPoints();
|
||||||
|
_Round += num;
|
||||||
|
_Round = _Round.Clamp(0, points.NumRounds - 1);
|
||||||
|
}
|
||||||
|
|
||||||
_UpdateRound();
|
_UpdateRound();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ namespace Vocaluxe.Screens
|
|||||||
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
// Version number for theme files. Increment it, if you've changed something on the theme files!
|
||||||
protected override int _ScreenVersion
|
protected override int _ScreenVersion
|
||||||
{
|
{
|
||||||
get { return 7; }
|
get { return 8; }
|
||||||
}
|
}
|
||||||
|
|
||||||
private const string _TextCategory = "TextCategory";
|
private const string _TextCategory = "TextCategory";
|
||||||
@@ -66,6 +66,7 @@ namespace Vocaluxe.Screens
|
|||||||
private const string _ButtonOptionsRandomMedley = "ButtonOptionsRandomMedley";
|
private const string _ButtonOptionsRandomMedley = "ButtonOptionsRandomMedley";
|
||||||
private const string _ButtonOptionsStartMedley = "ButtonOptionsStartMedley";
|
private const string _ButtonOptionsStartMedley = "ButtonOptionsStartMedley";
|
||||||
private const string _ButtonStart = "ButtonStart";
|
private const string _ButtonStart = "ButtonStart";
|
||||||
|
private const string _ButtonOptionsHighscore = "ButtonOptionsHighscore";
|
||||||
|
|
||||||
private const string _SelectSlideOptionsMode = "SelectSlideOptionsMode";
|
private const string _SelectSlideOptionsMode = "SelectSlideOptionsMode";
|
||||||
private const string _SelectSlideOptionsPlaylistAdd = "SelectSlideOptionsPlaylistAdd";
|
private const string _SelectSlideOptionsPlaylistAdd = "SelectSlideOptionsPlaylistAdd";
|
||||||
@@ -99,6 +100,18 @@ namespace Vocaluxe.Screens
|
|||||||
private ISongMenu _SongMenu;
|
private ISongMenu _SongMenu;
|
||||||
private CPlaylist _Playlist;
|
private CPlaylist _Playlist;
|
||||||
|
|
||||||
|
private static int _StaticSelectedSongID;
|
||||||
|
|
||||||
|
private static void setStaticSelectedSongID(int songID)
|
||||||
|
{
|
||||||
|
_StaticSelectedSongID = songID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getSelectedSongID()
|
||||||
|
{
|
||||||
|
return _StaticSelectedSongID;
|
||||||
|
}
|
||||||
|
|
||||||
public override EMusicType CurrentMusicType
|
public override EMusicType CurrentMusicType
|
||||||
{
|
{
|
||||||
get { return CSongs.IsInCategory ? EMusicType.Preview : EMusicType.Background; }
|
get { return CSongs.IsInCategory ? EMusicType.Preview : EMusicType.Background; }
|
||||||
@@ -130,6 +143,7 @@ namespace Vocaluxe.Screens
|
|||||||
blist.Add(_ButtonStart);
|
blist.Add(_ButtonStart);
|
||||||
blist.Add(_ButtonOptionsRandomMedley);
|
blist.Add(_ButtonOptionsRandomMedley);
|
||||||
blist.Add(_ButtonOptionsStartMedley);
|
blist.Add(_ButtonOptionsStartMedley);
|
||||||
|
blist.Add(_ButtonOptionsHighscore);
|
||||||
|
|
||||||
_TextsPlayer.Clear();
|
_TextsPlayer.Clear();
|
||||||
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
|
||||||
@@ -303,6 +317,13 @@ namespace Vocaluxe.Screens
|
|||||||
if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode)
|
if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode)
|
||||||
_StartMedleySong(_SongMenu.GetPreviewSongNr());
|
_StartMedleySong(_SongMenu.GetPreviewSongNr());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case Keys.H:
|
||||||
|
if (keyEvent.Mod == EModifier.Ctrl && CSongs.NumSongsVisible > 0 && !_Sso.Selection.PartyMode)
|
||||||
|
{
|
||||||
|
_ShowHighscore();
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (!_SearchActive)
|
if (!_SearchActive)
|
||||||
{
|
{
|
||||||
@@ -400,6 +421,10 @@ namespace Vocaluxe.Screens
|
|||||||
_ToggleSongOptions(ESongOptionsView.None);
|
_ToggleSongOptions(ESongOptionsView.None);
|
||||||
_StartRandomMedley(_SelectSlides[_SelectSlideOptionsNumMedleySongs].Selection + 1, !CSongs.IsInCategory);
|
_StartRandomMedley(_SelectSlides[_SelectSlideOptionsNumMedleySongs].Selection + 1, !CSongs.IsInCategory);
|
||||||
}
|
}
|
||||||
|
else if (_Buttons[_ButtonOptionsHighscore].Selected)
|
||||||
|
{
|
||||||
|
_ShowHighscore();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
@@ -575,6 +600,10 @@ namespace Vocaluxe.Screens
|
|||||||
_StartRandomMedley(_SelectSlides[_SelectSlideOptionsNumMedleySongs].Selection + 1, !CSongs.IsInCategory);
|
_StartRandomMedley(_SelectSlides[_SelectSlideOptionsNumMedleySongs].Selection + 1, !CSongs.IsInCategory);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
else if (_Buttons[_ButtonOptionsHighscore].Selected)
|
||||||
|
{
|
||||||
|
_ShowHighscore();
|
||||||
|
}
|
||||||
else if (_Sso.Selection.RandomOnly && _Sso.Selection.NumJokers != null)
|
else if (_Sso.Selection.RandomOnly && _Sso.Selection.NumJokers != null)
|
||||||
{
|
{
|
||||||
if (_Buttons[_ButtonStart].Selected)
|
if (_Buttons[_ButtonStart].Selected)
|
||||||
@@ -864,6 +893,13 @@ namespace Vocaluxe.Screens
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _ShowHighscore()
|
||||||
|
{
|
||||||
|
CGame.ClearSongs();
|
||||||
|
CScreenSong.setStaticSelectedSongID(CSongs.VisibleSongs[_SongMenu.GetPreviewSongNr()].ID);
|
||||||
|
CBase.Graphics.FadeTo(EScreen.Highscore);
|
||||||
|
}
|
||||||
|
|
||||||
private void _StartSong(int songNr)
|
private void _StartSong(int songNr)
|
||||||
{
|
{
|
||||||
if (CSongs.IsInCategory && (songNr >= 0))
|
if (CSongs.IsInCategory && (songNr >= 0))
|
||||||
@@ -1185,6 +1221,7 @@ namespace Vocaluxe.Screens
|
|||||||
_Buttons[_ButtonOptionsOpenSelectedItem].Visible = false;
|
_Buttons[_ButtonOptionsOpenSelectedItem].Visible = false;
|
||||||
_Buttons[_ButtonOptionsRandomMedley].Visible = false;
|
_Buttons[_ButtonOptionsRandomMedley].Visible = false;
|
||||||
_Buttons[_ButtonOptionsStartMedley].Visible = false;
|
_Buttons[_ButtonOptionsStartMedley].Visible = false;
|
||||||
|
_Buttons[_ButtonOptionsHighscore].Visible = false;
|
||||||
_Texts[_TextOptionsTitle].Visible = false;
|
_Texts[_TextOptionsTitle].Visible = false;
|
||||||
_Statics[_StaticOptionsBG].Visible = false;
|
_Statics[_StaticOptionsBG].Visible = false;
|
||||||
_Buttons[_ButtonOpenOptions].Visible = true;
|
_Buttons[_ButtonOpenOptions].Visible = true;
|
||||||
@@ -1241,6 +1278,7 @@ namespace Vocaluxe.Screens
|
|||||||
_SelectSlides[_SelectSlideOptionsPlaylistAdd].Visible = true;
|
_SelectSlides[_SelectSlideOptionsPlaylistAdd].Visible = true;
|
||||||
_Buttons[_ButtonOptionsSing].Visible = true;
|
_Buttons[_ButtonOptionsSing].Visible = true;
|
||||||
_Buttons[_ButtonOptionsPlaylist].Visible = true;
|
_Buttons[_ButtonOptionsPlaylist].Visible = true;
|
||||||
|
_Buttons[_ButtonOptionsHighscore].Visible = true;
|
||||||
_SelectElement(_Buttons[_ButtonOptionsSing]);
|
_SelectElement(_Buttons[_ButtonOptionsSing]);
|
||||||
_SetSelectSlidePlaylistToCurrentPlaylist();
|
_SetSelectSlidePlaylistToCurrentPlaylist();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
|||||||
EScreen check = CBase.Graphics.GetNextScreenType();
|
EScreen check = CBase.Graphics.GetNextScreenType();
|
||||||
if (CBase.Graphics.GetNextScreenType() == EScreen.Sing)
|
if (CBase.Graphics.GetNextScreenType() == EScreen.Sing)
|
||||||
_ResetPreview(false);
|
_ResetPreview(false);
|
||||||
else if (CBase.Graphics.GetNextScreenType() != EScreen.Names || CBase.Config.GetBackgroundMusicStatus() == EBackgroundMusicOffOn.TR_CONFIG_OFF)
|
else if ((CBase.Graphics.GetNextScreenType() != EScreen.Names && CBase.Graphics.GetNextScreenType() != EScreen.Highscore) || CBase.Config.GetBackgroundMusicStatus() == EBackgroundMusicOffOn.TR_CONFIG_OFF)
|
||||||
_ResetPreview();
|
_ResetPreview();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user