Added function to select a random category.

This commit is contained in:
Florian Kuepper committed 2012-12-01 22:05:45 +01:00
1 parent b10a10cc9f
commit 26a5086fc8
10 files changed
+179 -3

No files matched your search

+1
View File
@@ -123,6 +123,7 @@
<TR_SCREENSONG_BUTTON_PLAYLIST>Zur Playlist hinzufügen</TR_SCREENSONG_BUTTON_PLAYLIST>
<TR_SCREENSONG_BUTTON_CANCEL>Schließen</TR_SCREENSONG_BUTTON_CANCEL>
<TR_SCREENSONG_BUTTON_RANDOM>Zufälligen Song wählen</TR_SCREENSONG_BUTTON_RANDOM>
<TR_SCREENSONG_BUTTON_RANDOMCAT>Zufällige Kategorie wählen</TR_SCREENSONG_BUTTON_RANDOMCAT>
<TR_SCREENSONG_BUTTON_SINGALL>Alle Songs singen</TR_SCREENSONG_BUTTON_SINGALL>
<TR_SCREENSONG_BUTTON_SINGALLVISIBLE>Alle sichtbaren Song singen</TR_SCREENSONG_BUTTON_SINGALLVISIBLE>
<TR_SCREENSONG_BUTTON_OPENPLAYLIST>Playlist öffnen</TR_SCREENSONG_BUTTON_OPENPLAYLIST>
+1
View File
@@ -123,6 +123,7 @@
<TR_SCREENSONG_BUTTON_PLAYLIST>Add to playlist</TR_SCREENSONG_BUTTON_PLAYLIST>
<TR_SCREENSONG_BUTTON_CANCEL>Close</TR_SCREENSONG_BUTTON_CANCEL>
<TR_SCREENSONG_BUTTON_RANDOM>Select a random song</TR_SCREENSONG_BUTTON_RANDOM>
<TR_SCREENSONG_BUTTON_RANDOMCAT>Select a random category</TR_SCREENSONG_BUTTON_RANDOMCAT>
<TR_SCREENSONG_BUTTON_SINGALL>Sing all songs</TR_SCREENSONG_BUTTON_SINGALL>
<TR_SCREENSONG_BUTTON_SINGALLVISIBLE>Sing all visible songs</TR_SCREENSONG_BUTTON_SINGALLVISIBLE>
<TR_SCREENSONG_BUTTON_OPENPLAYLIST>Open playlist</TR_SCREENSONG_BUTTON_OPENPLAYLIST>
@@ -473,6 +473,55 @@
<!-- <Space>: Reflection Space of selected button-->
<!-- <Height>: Reflection Height of selected button-->
</ButtonOptionsSingAllVisible>
<ButtonOptionsRandomCategory>
<!--<Skin>: Texture name-->
<Skin>Button</Skin>
<!--<SkinSelected>: Texture name for selected button-->
<SkinSelected>Button</SkinSelected>
<!--<X>, <Y>, <Z>, <W>, <H>: Button position, width and height-->
<X>40</X>
<Y>90</Y>
<Z>-2,11</Z>
<W>360</W>
<H>40</H>
<!--<Color>: Button color from ColorScheme (high priority)-->
<!--or <R>, <G>, <B>, <A> (lower priority)-->
<Color>ButtonColor</Color>
<!--<SColor>: Selected button color from ColorScheme (high priority)-->
<!--or <SR>, <SG>, <SB>, <SA> (lower priority)-->
<SColor>ButtonSColor</SColor>
<Text>
<!--<X>, <Y>: Text position-->
<X>180</X>
<Y>5</Y>
<!--<H>: Text height-->
<H>30</H>
<!--<MaxW>: Maximum text width (if exists)-->
<MaxW>350</MaxW>
<!--<Color>: Text color from ColorScheme (high priority)-->
<!--or <R>, <G>, <B>, <A> (lower priority)-->
<Color>ButtonTextColor</Color>
<!--<SColor>: Selected Text color from ColorScheme (high priority)-->
<!--or <SR>, <SG>, <SB>, <SA> (lower priority)-->
<SColor>ButtonTextSColor</SColor>
<!--<Align>: Text align horizontal: Left, Center, Right-->
<Align>Center</Align>
<!--<HAlign>: Text align vertical (on downsizing): Top, Center, Bottom-->
<HAlign>Center</HAlign>
<!--<Style>: Text style: Normal, Italic, Bold, BoldItalic-->
<Style>Bold</Style>
<!--<Font>: Text font name-->
<Font>Outline</Font>
<!--<Text>: Nothing or translation tag-->
<Text>TR_SCREENSONG_BUTTON_RANDOMCAT</Text>
</Text>
<!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height-->
<!--<SReflection> If exists:-->
<!-- <Space>: Reflection Space of selected button-->
<!-- <Height>: Reflection Height of selected button-->
</ButtonOptionsRandomCategory>
<ButtonOptionsRandom>
<!--<Skin>: Texture name-->
<Skin>Button</Skin>
@@ -6,7 +6,7 @@ Version 3:
Add:
<StaticOptionsBG>
<TextOptionsTitle>
<ButtonOptionsSing>, <ButtonOptionsClose>, <ButtonOptionsPlaylist>, <ButtonOptionsSingAll>, <ButtonOptionsSingAllVisible>, <ButtonOptionsRandom>, <ButtonOptionsRandom>, <ButtonOpenOptions>
<ButtonOptionsSing>, <ButtonOptionsClose>, <ButtonOptionsPlaylist>, <ButtonOptionsSingAll>, <ButtonOptionsSingAllVisible>, <ButtonOptionsRandom>, <ButtonOptionsRandom>, <ButtonOptionsRandomCategory>, <ButtonOpenOptions>
<SelectSlideOptionsMode>, <SelectSlideOptionsPlaylistAdd>, <SelectSlideOptionsPlaylistOpen>
and
<Playlist> as a new Screen-Element. For details, look at ScreenSong.xml
+30
View File
@@ -56,6 +56,7 @@ namespace Vocaluxe.Base
private static int _CoverLoadIndex = -1;
private static int _CatIndex = -1;
private static List<CCategory> _Categories = new List<CCategory>();
private static List<CCategory> _CategoriesForRandom = new List<CCategory>();
private static Stopwatch _CoverLoadTimer = new Stopwatch();
@@ -275,6 +276,35 @@ namespace Vocaluxe.Base
_SongsForRandom.AddRange(VisibleSongs);
}
public static int GetRandomCategory()
{
if (_CategoriesForRandom.Count == 0)
UpdateRandomCategoryList();
if (_CategoriesForRandom.Count == 0)
return -1;
CCategory category = _CategoriesForRandom[CGame.Rand.Next(0, _CategoriesForRandom.Count - 1)];
_CategoriesForRandom.Remove(category);
return GetCategoryNumber(category);
}
public static void UpdateRandomCategoryList()
{
_CategoriesForRandom.Clear();
_CategoriesForRandom.AddRange(Categories);
}
private static int GetCategoryNumber(CCategory category)
{
for (int i = 0; i < Categories.Length; i++)
{
if (Categories[i] == category)
return i;
}
return -1;
}
public static CSong[] AllSongs
{
get { return _Songs.ToArray(); }
+5
View File
@@ -98,6 +98,11 @@ namespace Vocaluxe.Menu.SongMenu
return _SongMenu.GetSelectedCategory();
}
public void SetSelectedCategory(int CategoryNr)
{
_SongMenu.SetSelectedCategory(CategoryNr);
}
public int GetActualSelection()
{
return _SongMenu.GetActualSelection();
@@ -536,6 +536,12 @@ namespace Vocaluxe.Menu.SongMenu
return;
}
public virtual void SetSelectedCategory(int CategoryNr)
{
if (!_Initialized)
return;
}
public virtual void SetSmallView(bool SmallView)
{
if (!_Initialized)
@@ -556,6 +556,62 @@ namespace Vocaluxe.Menu.SongMenu
}
public override void SetSelectedCategory(int CategoryNr)
{
base.SetSelectedCategory(CategoryNr);
if (CategoryNr < 0)
return;
if (CSongs.Categories.Length > CategoryNr)
{
bool sel = false;
foreach (CStatic tile in _Tiles)
{
if (tile.Selected)
{
sel = true;
break;
}
}
if (_Locked == -1 || !sel)
{
if (_PreviewSelected > -1)
{
_Locked = _PreviewSelected;
}
else
{
_Locked = 0;
_actualSelection = 0;
_PreviewSelected = 0;
SetSelectedNow();
UpdateList(0);
}
}
foreach (CStatic tile in _Tiles)
{
tile.Selected = false;
}
_PreviewSelected = CategoryNr;
SetSelectedNow();
_Locked = CategoryNr;
UpdateList((CategoryNr / _NumW) * _NumW - (_NumW * (_NumH - 2)));
_PreviewSelected = _Locked;
_actualSelection = _Locked;
for (int i = 0; i < _Tiles.Count; i++)
{
_Tiles[i].Selected = _Locked == i + _Offset;
}
}
}
protected override void EnterCategory(int cat)
{
base.EnterCategory(cat);
+1
View File
@@ -24,6 +24,7 @@ namespace Vocaluxe.Menu.SongMenu
void SetActive(bool Active);
int GetSelectedCategory();
void SetSelectedCategory(int CategoryNr);
int GetActualSelection();
bool IsSelected();
+29 -2
View File
@@ -38,6 +38,7 @@ namespace Vocaluxe.Screens
private const string ButtonOptionsPlaylist = "ButtonOptionsPlaylist";
private const string ButtonOptionsClose = "ButtonOptionsClose";
private const string ButtonOptionsRandom = "ButtonOptionsRandom";
private const string ButtonOptionsRandomCategory = "ButtonOptionsRandomCategory";
private const string ButtonOptionsSingAll = "ButtonOptionsSingAll";
private const string ButtonOptionsSingAllVisible = "ButtonOptionsSingAllVisible";
private const string ButtonOptionsOpenPlaylist = "ButtonOptionsOpenPlaylist";
@@ -73,7 +74,7 @@ namespace Vocaluxe.Screens
_ScreenVersion = ScreenVersion;
_ThemeStatics = new string[] { StaticSearchBar, StaticOptionsBG };
_ThemeTexts = new string[] { TextCategory, TextSelection, TextSearchBarTitle, TextSearchBar, TextOptionsTitle };
_ThemeButtons = new string[] { ButtonOptionsClose, ButtonOptionsPlaylist, ButtonOptionsSing, ButtonOptionsRandom, ButtonOptionsSingAll, ButtonOptionsSingAllVisible, ButtonOptionsOpenPlaylist, ButtonOpenOptions };
_ThemeButtons = new string[] { ButtonOptionsClose, ButtonOptionsPlaylist, ButtonOptionsSing, ButtonOptionsRandom, ButtonOptionsRandomCategory, ButtonOptionsSingAll, ButtonOptionsSingAllVisible, ButtonOptionsOpenPlaylist, ButtonOpenOptions };
_ThemeSelectSlides = new string[] { SelectSlideOptionsMode, SelectSlideOptionsPlaylistAdd, SelectSlideOptionsPlaylistOpen };
_ThemeSongMenus = new string[] { SongMenu };
_ThemePlaylists = new string[] { Playlist };
@@ -89,6 +90,7 @@ namespace Vocaluxe.Screens
Buttons[htButtons(ButtonOptionsSing)].Visible = false;
Buttons[htButtons(ButtonOptionsPlaylist)].Visible = false;
Buttons[htButtons(ButtonOptionsRandom)].Visible = false;
Buttons[htButtons(ButtonOptionsRandomCategory)].Visible = false;
Buttons[htButtons(ButtonOptionsSingAll)].Visible = false;
Buttons[htButtons(ButtonOptionsSingAllVisible)].Visible = false;
Buttons[htButtons(ButtonOptionsOpenPlaylist)].Visible = false;
@@ -223,6 +225,10 @@ namespace Vocaluxe.Screens
{
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
}
else if (CSongs.Category == -1 && KeyEvent.Mod == Modifier.Ctrl)
{
SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory());
}
break;
//TODO: Delete that!
@@ -259,6 +265,13 @@ namespace Vocaluxe.Screens
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
}
}
else if (Buttons[htButtons(ButtonOptionsRandom)].Selected)
{
if (CSongs.Category == -1)
{
SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory());
}
}
else if (Buttons[htButtons(ButtonOptionsSingAll)].Selected)
{
StartRandomAllSongs();
@@ -319,6 +332,11 @@ namespace Vocaluxe.Screens
Console.WriteLine("MB pressed");
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
}
else if (MouseEvent.MB && CSongs.Category == -1)
{
Console.WriteLine("MB pressed");
SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory());
}
else
SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent);
@@ -362,6 +380,13 @@ namespace Vocaluxe.Screens
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(CSongs.GetRandomSong());
}
}
else if (Buttons[htButtons(ButtonOptionsRandomCategory)].Selected)
{
if (CSongs.Category == -1)
{
SongMenus[htSongMenus(SongMenu)].SetSelectedCategory(CSongs.GetRandomCategory());
}
}
else if (Buttons[htButtons(ButtonOptionsSingAll)].Selected)
{
ToggleSongOptions(ESongOptionsView.None);
@@ -648,8 +673,9 @@ namespace Vocaluxe.Screens
else if (view == ESongOptionsView.General)
{
Buttons[htButtons(ButtonOptionsRandom)].Visible = CSongs.Category != -1;
Buttons[htButtons(ButtonOptionsRandomCategory)].Visible = CSongs.Category == -1;
Buttons[htButtons(ButtonOptionsSingAll)].Visible = true;
Buttons[htButtons(ButtonOptionsSingAllVisible)].Visible = true;
Buttons[htButtons(ButtonOptionsSingAllVisible)].Visible = CSongs.Category != -1; ;
Buttons[htButtons(ButtonOptionsOpenPlaylist)].Visible = true;
SelectSlides[htSelectSlides(SelectSlideOptionsPlaylistOpen)].Visible = true;
}
@@ -666,6 +692,7 @@ namespace Vocaluxe.Screens
Buttons[htButtons(ButtonOptionsSing)].Visible = false;
Buttons[htButtons(ButtonOptionsPlaylist)].Visible = false;
Buttons[htButtons(ButtonOptionsRandom)].Visible = false;
Buttons[htButtons(ButtonOptionsRandomCategory)].Visible = false;
Buttons[htButtons(ButtonOptionsSingAll)].Visible = false;
Buttons[htButtons(ButtonOptionsSingAllVisible)].Visible = false;
Buttons[htButtons(ButtonOptionsOpenPlaylist)].Visible = false;