On change of Tabs to on it will go out of any category

Auto reformat
This commit is contained in:
Flamefire committed 2013-04-29 02:24:36 +02:00
1 parent cf0fd9dbed
commit 69c36362f5
15 files changed
+168 -39

No files matched your search

@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Runtime.InteropServices;
using VocaluxeLib.Menu;
using VocaluxeLib.Menu.SongMenu;
@@ -504,7 +505,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
List<int> ids = new List<int>();
var visibleSongs = CBase.Songs.GetVisibleSongs();
ReadOnlyCollection<CSong> visibleSongs = CBase.Songs.GetVisibleSongs();
if (visibleSongs.Count == 0)
{
CBase.Log.LogError("CPartyChallengeMedleyMode Error: There are no songs!");
+5
View File
@@ -584,6 +584,11 @@ namespace Vocaluxe.Base
return CSongs.NumSongsInCategory(categoryIndex);
}
public bool IsInCategory()
{
return CSongs.IsInCategory;
}
public int GetCurrentCategoryIndex()
{
return CSongs.Category;
+2 -1
View File
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Text;
using Vocaluxe.Lib.Playlist;
@@ -223,7 +224,7 @@ namespace Vocaluxe.Base
private static CPlaylistFile _ConvertUSDXPlaylist(string file)
{
CPlaylistFile pl = new CPlaylistFile();
var allSongs = CSongs.AllSongs;
ReadOnlyCollection<CSong> allSongs = CSongs.AllSongs;
if (!File.Exists(file))
return null;
+2
View File
@@ -52,6 +52,8 @@ namespace Vocaluxe.Base
if (value == _Tabs)
return;
_Tabs = value;
if (_Tabs == EOffOn.TR_CONFIG_ON)
CSongs.Category = -1;
_SetChanged();
}
}
+14 -10
View File
@@ -76,20 +76,25 @@ namespace Vocaluxe.Base
public static int Category
{
get { return _CatIndex; }
get
{
if (_CatIndex >= Categories.Count)
_CatIndex = -1;
return _CatIndex;
}
set
{
if (value == -1 || IsCatIndexValid(value))
if (value == -1 || _IsCatIndexValid(value))
_CatIndex = value;
}
}
public static bool IsInCategory
{
get { return _CatIndex >= 0; }
get { return _IsCatIndexValid(_CatIndex); }
}
private static bool IsCatIndexValid(int catIndex)
private static bool _IsCatIndexValid(int catIndex)
{
return catIndex >= 0 && catIndex < Categories.Count;
}
@@ -101,7 +106,7 @@ namespace Vocaluxe.Base
/// <returns></returns>
public static int NumSongsInCategory(int catIndex)
{
return IsCatIndexValid(catIndex) ? Categories[catIndex].Songs.Count(sp => !sp.IsSung) : 0;
return _IsCatIndexValid(catIndex) ? Categories[catIndex].Songs.Count(sp => !sp.IsSung) : 0;
}
public static void NextCategory()
@@ -139,7 +144,7 @@ namespace Vocaluxe.Base
public static string GetCurrentCategoryName()
{
return IsCatIndexValid(_CatIndex) ? Categories[_CatIndex].Name : "";
return _IsCatIndexValid(_CatIndex) ? Categories[_CatIndex].Name : "";
}
public static CSong GetSong(int songID)
@@ -170,7 +175,7 @@ namespace Vocaluxe.Base
public static void ResetPartySongSung(int catIndex)
{
if (IsCatIndexValid(catIndex))
if (_IsCatIndexValid(catIndex))
{
foreach (CSongPointer song in Categories[catIndex].Songs)
song.IsSung = false;
@@ -247,7 +252,7 @@ namespace Vocaluxe.Base
get
{
List<CSong> songs = new List<CSong>();
if (IsCatIndexValid(_CatIndex))
if (_IsCatIndexValid(_CatIndex))
{
foreach (CSongPointer sp in Categories[_CatIndex].Songs)
{
@@ -268,14 +273,13 @@ namespace Vocaluxe.Base
{
if (index < 0)
return null;
var visSongs = VisibleSongs;
ReadOnlyCollection<CSong> visSongs = VisibleSongs;
return (index < visSongs.Count) ? visSongs[index] : null;
}
private static void _HandleCategoriesChanged(object sender, EventArgs args)
{
_CategoriesForRandom.Clear();
Category = _CatIndex;
}
public static void Sort(ESongSorting sorting, EOffOn tabs, EOffOn ignoreArticles, String searchString, EDuetOptions duetOptions)
+19
View File
@@ -1,3 +1,22 @@
#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.Collections.Generic;
using System.Drawing;
using System.IO;
+19
View File
@@ -1,3 +1,22 @@
#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.Drawing;
using System.Drawing.Drawing2D;
+19
View File
@@ -1,3 +1,22 @@
#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 Vocaluxe.Base;
using VocaluxeLib.Menu.SongMenu;
+20 -1
View File
@@ -1,4 +1,23 @@
using System;
#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.Linq;
using System.Text;
+20 -1
View File
@@ -1,4 +1,23 @@
using VocaluxeLib.Menu.SongMenu;
#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 VocaluxeLib.Menu.SongMenu;
namespace Vocaluxe.GameModes
{
+3 -2
View File
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using Vocaluxe.Base;
using VocaluxeLib.Menu;
@@ -1007,7 +1008,7 @@ namespace Vocaluxe.Screens
if (CSongs.IsInCategory)
{
//TODO: Check and use sorting method
var songs = CSongs.VisibleSongs;
ReadOnlyCollection<CSong> songs = CSongs.VisibleSongs;
int ct = songs.Count;
if (curSelected >= 0 && curSelected < ct - 1 && songs[curSelected].Artist.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
@@ -1017,7 +1018,7 @@ namespace Vocaluxe.Screens
}
else
{
var categories = CSongs.Categories;
ReadOnlyCollection<CCategory> categories = CSongs.Categories;
int ct = categories.Count;
if (curSelected >= 0 && curSelected < ct - 1 && categories[curSelected].Name.StartsWith(letter.ToString(), StringComparison.OrdinalIgnoreCase))
start = curSelected + 1;
+1
View File
@@ -244,6 +244,7 @@ namespace VocaluxeLib.Menu
int GetNumSongsVisible();
int GetNumCategories();
int NumSongsInCategory(int categoryIndex);
bool IsInCategory();
int GetCurrentCategoryIndex();
EOffOn GetTabs();
+20 -1
View File
@@ -1,4 +1,23 @@
using System.Collections.Generic;
#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.Collections.Generic;
namespace VocaluxeLib.Menu.SongMenu
{
@@ -559,7 +559,7 @@ namespace VocaluxeLib.Menu.SongMenu
{
if (!_Initialized)
return false;
if (CBase.Songs.GetCurrentCategoryIndex() >= 0 || _PreviewSelected < 0 || _PreviewSelected >= CBase.Songs.GetNumCategories())
if (CBase.Songs.IsInCategory() || _PreviewSelected < 0 || _PreviewSelected >= CBase.Songs.GetNumCategories())
return false;
_EnterCategory(_PreviewSelected);
return true;
@@ -582,7 +582,7 @@ namespace VocaluxeLib.Menu.SongMenu
if (!_Initialized)
return;
if (CBase.Songs.GetCurrentCategoryIndex() == -1)
if (!CBase.Songs.IsInCategory())
return;
_Reset();
@@ -596,7 +596,7 @@ namespace VocaluxeLib.Menu.SongMenu
protected void _SelectSong(int nr)
{
if (CBase.Songs.GetCurrentCategoryIndex() >= 0 && (CBase.Songs.GetNumSongsVisible() > 0) && (nr >= 0) && ((_Actsong != nr) || (_Streams.Count == 0)))
if (CBase.Songs.IsInCategory() && (CBase.Songs.GetNumSongsVisible() > 0) && (nr >= 0) && ((_Actsong != nr) || (_Streams.Count == 0)))
{
_Streams.ForEach(soundStream => CBase.Sound.FadeAndStop(soundStream, 0f, 1f));
_Streams.Clear();
+19 -19
View File
@@ -129,7 +129,7 @@ namespace VocaluxeLib.Menu.SongMenu
public override void OnShow()
{
if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && CBase.Songs.GetNumCategories() > 0 && CBase.Songs.GetCurrentCategoryIndex() == -1)
if (CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && CBase.Songs.GetNumCategories() > 0 && !CBase.Songs.IsInCategory())
_EnterCategory(0);
_ActualSelection = -1;
_Locked = -1;
@@ -201,7 +201,7 @@ namespace VocaluxeLib.Menu.SongMenu
switch (keyEvent.Key)
{
case Keys.Enter:
if (CBase.Songs.GetCurrentCategoryIndex() < 0)
if (!CBase.Songs.IsInCategory())
{
_EnterCategory(_PreviewSelected);
keyEvent.Handled = true;
@@ -212,7 +212,7 @@ namespace VocaluxeLib.Menu.SongMenu
case Keys.Escape:
case Keys.Back:
if (CBase.Songs.GetCurrentCategoryIndex() > -1 && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && songOptions.Selection.CategoryChangeAllowed)
if (CBase.Songs.IsInCategory() && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && songOptions.Selection.CategoryChangeAllowed)
{
_ShowCategories();
keyEvent.Handled = true;
@@ -234,7 +234,7 @@ namespace VocaluxeLib.Menu.SongMenu
break;
case Keys.Left:
if (_Locked > 0 && (!songOptions.Selection.RandomOnly || songOptions.Selection.CategoryChangeAllowed && CBase.Songs.GetCurrentCategoryIndex() < 0))
if (_Locked > 0 && (!songOptions.Selection.RandomOnly || songOptions.Selection.CategoryChangeAllowed && !CBase.Songs.IsInCategory()))
{
_Locked--;
_UpdateList();
@@ -242,7 +242,7 @@ namespace VocaluxeLib.Menu.SongMenu
break;
case Keys.Right:
if (CBase.Songs.GetCurrentCategoryIndex() < 0 && songOptions.Selection.CategoryChangeAllowed)
if (!CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed)
{
if (_Locked < CBase.Songs.GetNumCategories() - 1)
{
@@ -252,7 +252,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
else
{
if (CBase.Songs.GetCurrentCategoryIndex() != -1 && _Locked < CBase.Songs.GetNumSongsVisible() - 1 && !songOptions.Selection.RandomOnly)
if (CBase.Songs.IsInCategory() && _Locked < CBase.Songs.GetNumSongsVisible() - 1 && !songOptions.Selection.RandomOnly)
{
_Locked++;
_UpdateList();
@@ -268,7 +268,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
if (_Locked > _NumW - 1 &&
(!songOptions.Selection.RandomOnly || songOptions.Selection.CategoryChangeAllowed && CBase.Songs.GetCurrentCategoryIndex() < 0))
(!songOptions.Selection.RandomOnly || songOptions.Selection.CategoryChangeAllowed && !CBase.Songs.IsInCategory()))
{
_Locked -= _NumW;
_UpdateList();
@@ -282,7 +282,7 @@ namespace VocaluxeLib.Menu.SongMenu
break;
}
if (CBase.Songs.GetCurrentCategoryIndex() < 0 && songOptions.Selection.CategoryChangeAllowed)
if (!CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed)
{
if (_Locked < CBase.Songs.GetNumCategories() - _NumW)
{
@@ -318,13 +318,13 @@ namespace VocaluxeLib.Menu.SongMenu
bool sel = false;
int lastselection = _ActualSelection;
if (!songOptions.Selection.RandomOnly || CBase.Songs.GetCurrentCategoryIndex() < 0 && songOptions.Selection.CategoryChangeAllowed)
if (!songOptions.Selection.RandomOnly || !CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed)
{
foreach (CStatic tile in _Tiles)
{
if ((tile.Texture.Index != _CoverTexture.Index) && CHelper.IsInBounds(tile.Rect, mouseEvent) && !sel)
{
if (mouseEvent.LB || CBase.Songs.GetCurrentCategoryIndex() == -1)
if (mouseEvent.LB || !CBase.Songs.IsInCategory())
{
if (_PreviewSelected == i + _Offset)
_Locked = _PreviewSelected;
@@ -352,7 +352,7 @@ namespace VocaluxeLib.Menu.SongMenu
if (!sel)
_ActualSelection = -1;
if (mouseEvent.RB && (CBase.Songs.GetNumCategories() > 0) && CBase.Songs.GetCurrentCategoryIndex() >= 0 && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON &&
if (mouseEvent.RB && (CBase.Songs.GetNumCategories() > 0) && CBase.Songs.IsInCategory() && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_ON &&
songOptions.Selection.CategoryChangeAllowed)
{
_ShowCategories();
@@ -366,7 +366,7 @@ namespace VocaluxeLib.Menu.SongMenu
if (CHelper.IsInBounds(_CoverBig.Rect, mouseEvent) || CHelper.IsInBounds(_TextBG.Rect, mouseEvent))
_Locked = _PreviewSelected;
}
else if (mouseEvent.LB && (CBase.Songs.GetCurrentCategoryIndex() == -1))
else if (mouseEvent.LB && (!CBase.Songs.IsInCategory()))
{
foreach (CStatic tile in _Tiles)
{
@@ -380,7 +380,7 @@ namespace VocaluxeLib.Menu.SongMenu
}
if (mouseEvent.Wheel != 0 && CHelper.IsInBounds(_ScrollRect, mouseEvent) &&
(!songOptions.Selection.RandomOnly || CBase.Songs.GetCurrentCategoryIndex() < 0 && songOptions.Selection.CategoryChangeAllowed))
(!songOptions.Selection.RandomOnly || !CBase.Songs.IsInCategory() && songOptions.Selection.CategoryChangeAllowed))
_UpdateList(_Offset + _NumW * mouseEvent.Wheel);
}
@@ -389,17 +389,17 @@ namespace VocaluxeLib.Menu.SongMenu
foreach (CStatic tile in _Tiles)
{
if (tile.Selected && _Active)
tile.Draw(1.2f, tile.Rect.Z - 0.1f, EAspect.Crop, false);
tile.Draw(1.2f, tile.Rect.Z - 0.1f, EAspect.Crop);
else
{
if (tile.Texture.Index != _CoverTexture.Index)
tile.Draw(1f, tile.Rect.Z, EAspect.Crop, false);
tile.Draw(1f, tile.Rect.Z, EAspect.Crop);
else
tile.Draw(1f, tile.Rect.Z, EAspect.Stretch, false);
tile.Draw(1f, tile.Rect.Z, EAspect.Stretch);
}
}
if (CBase.Songs.GetCurrentCategoryIndex() >= 0)
if (CBase.Songs.IsInCategory())
{
int actsong = _PreviewSelected;
if ((CBase.Songs.GetNumSongsVisible() > actsong) && (actsong >= 0))
@@ -490,7 +490,7 @@ namespace VocaluxeLib.Menu.SongMenu
return new CStatic(_PartyModeID);
}
protected void _SetSelectedTile(int itemNr)
private void _SetSelectedTile(int itemNr)
{
bool sel = _Tiles.Any(tile => tile.Selected);
@@ -607,7 +607,7 @@ namespace VocaluxeLib.Menu.SongMenu
private void _UpdateList(int offset, bool force = false)
{
bool isInCategory = CBase.Songs.GetCurrentCategoryIndex() >= 0;
bool isInCategory = CBase.Songs.IsInCategory();
int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
if (offset >= (itemCount / _NumW) * _NumW - (_NumW * (_NumH - 1)))