changed challenge party mode song selection (there are still some bugs)

This commit is contained in:
Alexander Eckart committed 2012-12-23 12:36:50 +01:00
1 parent e843569b3e
commit ee69919366
9 files changed
+220 -81

No files matched your search

+74 -11
View File
@@ -121,6 +121,8 @@ namespace Vocaluxe.PartyModes
public List<ResultTableRow> ResultTable;
public int CurrentRoundNr;
public int[] CatSongIndices;
}
struct Stats
@@ -161,7 +163,8 @@ namespace Vocaluxe.PartyModes
GameData.NumPlayerAtOnce = 2;
GameData.NumRounds = 2;
GameData.CurrentRoundNr = 1;
GameData.ProfileIDs = new List<int>();
GameData.ProfileIDs = new List<int>();
GameData.CatSongIndices = null;
}
public override bool Init()
@@ -169,8 +172,12 @@ namespace Vocaluxe.PartyModes
_Stage = EStage.NotStarted;
_ScreenSongOptions.Sorting.IgnoreArticles = _Base.Config.GetIgnoreArticles();
_ScreenSongOptions.Sorting.SongSorting = ESongSorting.TR_CONFIG_FOLDER;
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
_ScreenSongOptions.Sorting.SongSorting = _Base.Config.GetSongSorting();
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_OFF;
_ScreenSongOptions.Selection.SongIndex = -1;
if (_Base.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
ToScreenMain.ResultTable = new List<ResultTableRow>();
GameData.ResultTable = new List<ResultTableRow>();
@@ -250,10 +257,11 @@ namespace Vocaluxe.PartyModes
public override void UpdateGame()
{
if (_Base.Songs.GetCurrentCategoryIndex() != -1)
/*
if (_Base.Songs.GetCurrentCategoryIndex() != -1 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
_ScreenSongOptions.Selection.RandomOnly = true;
else
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.RandomOnly = false;*/
}
public override CMenuParty GetNextPartyScreen(out EScreens AlternativeScreen)
@@ -338,6 +346,48 @@ namespace Vocaluxe.PartyModes
return _ScreenSongOptions;
}
public override void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
{
if (_ScreenSongOptions.Selection.SongIndex != -1)
_ScreenSongOptions.Selection.SongIndex = -1;
if (_ScreenSongOptions.Selection.SelectNextRandomSong && SongIndex != -1)
{
_ScreenSongOptions.Selection.SelectNextRandomSong = false;
CreateCatSongIndices();
if (GameData.CatSongIndices != null)
{
if (GameData.CatSongIndices[_Base.Songs.GetCurrentCategoryIndex()] == -1)
GameData.CatSongIndices[_Base.Songs.GetCurrentCategoryIndex()] = SongIndex;
}
}
ScreenSongOptions = _ScreenSongOptions;
}
public override void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
{
if (GameData.CatSongIndices != null && CategoryIndex != -1)
{
if (GameData.CatSongIndices[CategoryIndex] == -1)
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
else
_ScreenSongOptions.Selection.SongIndex = GameData.CatSongIndices[CategoryIndex];
}
if (GameData.CatSongIndices == null && CategoryIndex != -1)
_ScreenSongOptions.Selection.SelectNextRandomSong = true;
if (CategoryIndex == -1)
_ScreenSongOptions.Selection.RandomOnly = false;
if (_ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF || CategoryIndex != -1)
_ScreenSongOptions.Selection.RandomOnly = true;
ScreenSongOptions = _ScreenSongOptions;
}
public override void SetSearchString(string SearchString, bool Visible)
{
_ScreenSongOptions.Sorting.SearchString = SearchString;
@@ -377,9 +427,7 @@ namespace Vocaluxe.PartyModes
if (TeamNr >= _ScreenSongOptions.Selection.NumJokers.Length)
return;
if (!_ScreenSongOptions.Selection.CategoryChangeAllowed)
_ScreenSongOptions.Selection.NumJokers[TeamNr]--;
_ScreenSongOptions.Selection.NumJokers[TeamNr]--;
_ScreenSongOptions.Selection.RandomOnly = true;
_ScreenSongOptions.Selection.CategoryChangeAllowed = false;
}
@@ -429,17 +477,17 @@ namespace Vocaluxe.PartyModes
public override void LeavingHighscore()
{
//TODO:
_Base.Graphics.FadeTo(EScreens.ScreenPartyDummy);
}
private void StartNextRound()
{
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
_ScreenSongOptions.Selection.RandomOnly = _ScreenSongOptions.Sorting.Tabs != EOffOn.TR_CONFIG_ON;
_ScreenSongOptions.Selection.CategoryChangeAllowed = _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON;
GameData.CurrentRoundNr++;
SetNumJokers();
SetTeamNames();
GameData.CatSongIndices = null;
_Base.Graphics.FadeTo(EScreens.ScreenSong);
}
@@ -619,5 +667,20 @@ namespace Vocaluxe.PartyModes
return result;
}
private void CreateCatSongIndices()
{
if (GameData.CatSongIndices == null && _Base.Songs.GetNumCategories() > 0 && _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_ON)
{
GameData.CatSongIndices = new int[_Base.Songs.GetNumCategories()];
for (int i = 0; i < GameData.CatSongIndices.Length; i++)
{
GameData.CatSongIndices[i] = -1;
}
}
if (_Base.Songs.GetNumCategories() == 0 || _ScreenSongOptions.Sorting.Tabs == EOffOn.TR_CONFIG_OFF)
GameData.CatSongIndices = null;
}
}
}
+10
View File
@@ -163,6 +163,16 @@ namespace Vocaluxe.Base
return _CurrentPartyMode.PartyMode.GetScreenSongOptions();
}
public static void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
{
_CurrentPartyMode.PartyMode.OnSongChange(SongIndex, ref ScreenSongOptions);
}
public static void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
{
_CurrentPartyMode.PartyMode.OnCategoryChange(CategoryIndex, ref ScreenSongOptions);
}
public static void SetSearchString(string SearchString, bool Visible)
{
_CurrentPartyMode.PartyMode.SetSearchString(SearchString, Visible);
+104 -65
View File
@@ -66,7 +66,10 @@ namespace Vocaluxe.Screens
private CStatic DragAndDropCover;
private bool DragAndDropActive;
private int OldMousePosX;
private int OldMousePosY;
private int OldMousePosY;
private int SelectedSongID;
private int SelectedCategoryIndex;
public CScreenSong()
{
@@ -183,6 +186,8 @@ namespace Vocaluxe.Screens
else
{
SongMenus[htSongMenus(SongMenu)].HandleInput(ref KeyEvent, _sso);
UpdatePartyModeOptions();
if (KeyEvent.Handled)
return true;
@@ -478,6 +483,10 @@ namespace Vocaluxe.Screens
}
SongMenus[htSongMenus(SongMenu)].HandleMouse(ref MouseEvent, _sso);
UpdatePartyModeOptions();
if (MouseEvent.Handled)
return true;
if (MouseEvent.LB)
{
@@ -614,6 +623,9 @@ namespace Vocaluxe.Screens
{
base.OnShow();
SelectedSongID = -1;
SelectedCategoryIndex = -2;
_sso = CParty.GetSongSelectionOptions();
CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString, _sso.Sorting.ShowDuetSongs);
_SearchActive = _sso.Sorting.SearchStringVisible;
@@ -643,19 +655,6 @@ namespace Vocaluxe.Screens
public override bool UpdateGame()
{
_sso = CParty.GetSongSelectionOptions();
CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString, _sso.Sorting.ShowDuetSongs);
_SearchActive = _sso.Sorting.SearchStringVisible;
_SearchText = _sso.Sorting.SearchString;
if (_sso.Selection.PartyMode)
_PlaylistActive = false;
if (_sso.Selection.PartyMode)
ToggleSongOptions(ESongOptionsView.None);
SongMenus[htSongMenus(SongMenu)].Update(_sso);
if (SongMenus[htSongMenus(SongMenu)].IsSmallView())
CheckPlaylist();
@@ -694,54 +693,7 @@ namespace Vocaluxe.Screens
Statics[htStatics(StaticSearchBar)].Visible = false;
}
if (_sso.Selection.RandomOnly && _sso.Selection.NumJokers != null)
{
Buttons[htButtons(ButtonStart)].Visible = true;
if(!SongMenus[htSongMenus(SongMenu)].IsSmallView())
SongMenus[htSongMenus(SongMenu)].SetSmallView(true);
for (int i = 0; i < _Base.Settings.GetMaxNumPlayer(); i++)
{
if (i < _sso.Selection.NumJokers.Length)
{
Buttons[htButtons(ButtonsJoker[i])].Visible = true;
Buttons[htButtons(ButtonsJoker[i])].Text.Text = _sso.Selection.NumJokers[i].ToString();
Texts[htTexts(TextsPlayer[i])].Visible = true;
bool NameExists = false;
if (_sso.Selection.TeamNames != null)
{
if (_sso.Selection.TeamNames.Length > i)
{
Texts[htTexts(TextsPlayer[i])].Text = _sso.Selection.TeamNames[i];
NameExists = true;
}
}
if (!NameExists)
Texts[htTexts(TextsPlayer[i])].Text = i.ToString();
}
else
{
Buttons[htButtons(ButtonsJoker[i])].Visible = false;
Texts[htTexts(TextsPlayer[i])].Visible = false;
}
}
}
else
{
if(_sso.Selection.PartyMode && SongMenus[htSongMenus(SongMenu)].IsSmallView())
SongMenus[htSongMenus(SongMenu)].SetSmallView(false);
for (int i = 0; i < _Base.Settings.GetMaxNumPlayer(); i++)
{
Buttons[htButtons(ButtonsJoker[i])].Visible = false;
Texts[htTexts(TextsPlayer[i])].Visible = false;
}
Buttons[htButtons(ButtonStart)].Visible = false;
}
UpdatePartyModeOptions();
return true;
}
@@ -782,6 +734,93 @@ namespace Vocaluxe.Screens
}
}
private void UpdatePartyModeOptions()
{
if (CSongs.Category == -1)
SelectedSongID = -1;
if (SelectedCategoryIndex != CSongs.Category)
{
SelectedCategoryIndex = CSongs.Category;
CParty.OnCategoryChange(SelectedCategoryIndex, ref _sso);
if (_sso.Selection.SelectNextRandomSong)
SelectNextRandomSong();
if (_sso.Selection.SongIndex != -1)
SongMenus[htSongMenus(SongMenu)].SetSelectedSong(_sso.Selection.SongIndex);
}
if (SelectedSongID != SongMenus[htSongMenus(SongMenu)].GetSelectedSong() && CSongs.Category > -1)
{
SelectedSongID = SongMenus[htSongMenus(SongMenu)].GetSelectedSong();
CParty.OnSongChange(SelectedSongID, ref _sso);
}
_sso = CParty.GetSongSelectionOptions();
CSongs.Sort(_sso.Sorting.SongSorting, _sso.Sorting.Tabs, _sso.Sorting.IgnoreArticles, _sso.Sorting.SearchString, _sso.Sorting.ShowDuetSongs);
_SearchActive = _sso.Sorting.SearchStringVisible;
_SearchText = _sso.Sorting.SearchString;
if (_sso.Selection.PartyMode)
{
_PlaylistActive = false;
ToggleSongOptions(ESongOptionsView.None);
}
SongMenus[htSongMenus(SongMenu)].Update(_sso);
if (_sso.Selection.RandomOnly && _sso.Selection.NumJokers != null)
{
Buttons[htButtons(ButtonStart)].Visible = true;
if (!SongMenus[htSongMenus(SongMenu)].IsSmallView())
SongMenus[htSongMenus(SongMenu)].SetSmallView(true);
for (int i = 0; i < _Base.Settings.GetMaxNumPlayer(); i++)
{
if (i < _sso.Selection.NumJokers.Length)
{
Buttons[htButtons(ButtonsJoker[i])].Visible = true;
Buttons[htButtons(ButtonsJoker[i])].Text.Text = _sso.Selection.NumJokers[i].ToString();
Texts[htTexts(TextsPlayer[i])].Visible = true;
bool NameExists = false;
if (_sso.Selection.TeamNames != null)
{
if (_sso.Selection.TeamNames.Length > i)
{
Texts[htTexts(TextsPlayer[i])].Text = _sso.Selection.TeamNames[i];
NameExists = true;
}
}
if (!NameExists)
Texts[htTexts(TextsPlayer[i])].Text = i.ToString();
}
else
{
Buttons[htButtons(ButtonsJoker[i])].Visible = false;
Texts[htTexts(TextsPlayer[i])].Visible = false;
}
}
}
else
{
if (_sso.Selection.PartyMode && SongMenus[htSongMenus(SongMenu)].IsSmallView())
SongMenus[htSongMenus(SongMenu)].SetSmallView(false);
for (int i = 0; i < _Base.Settings.GetMaxNumPlayer(); i++)
{
Buttons[htButtons(ButtonsJoker[i])].Visible = false;
Texts[htTexts(TextsPlayer[i])].Visible = false;
}
Buttons[htButtons(ButtonStart)].Visible = false;
}
}
private void StartSong(int SongNr)
{
if ((CSongs.Category >= 0) && (SongNr >= 0))
@@ -910,7 +949,7 @@ namespace Vocaluxe.Screens
{
if (_sso.Selection.NumJokers[TeamNr] > 0)
{
result = SelectNextRandomSong(TeamNr) || SelectNextRandomCategory();
result = SelectNextRandomSong() || SelectNextRandomCategory();
CParty.JokerUsed(TeamNr);
_sso = CParty.GetSongSelectionOptions();
}
@@ -919,12 +958,12 @@ namespace Vocaluxe.Screens
}
if (TeamNr == -1)
return SelectNextRandomSong(TeamNr) || SelectNextRandomCategory();
return SelectNextRandomSong() || SelectNextRandomCategory();
return false;
}
private bool SelectNextRandomSong(int TeamNr)
private bool SelectNextRandomSong()
{
if (CSongs.Category != -1)
{
+2
View File
@@ -371,6 +371,7 @@ namespace Vocaluxe.Menu
public struct MouseEvent
{
public ESender Sender;
public bool Handled;
public int X;
public int Y;
public bool LB; //left button click
@@ -392,6 +393,7 @@ namespace Vocaluxe.Menu
public MouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{
Sender = sender;
Handled = false;
X = x;
Y = y;
LB = lb;
@@ -599,6 +599,7 @@ namespace Vocaluxe.Menu.SongMenu
if (Category >= _Base.Songs.GetNumCategories())
return;
Reset();
_Base.Songs.SetCategory(Category);
}
@@ -610,6 +611,7 @@ namespace Vocaluxe.Menu.SongMenu
if (_Base.Songs.GetCurrentCategoryIndex() != -1)
Reset();
Reset();
_Base.Songs.SetCategory(-1);
}
@@ -105,6 +105,8 @@ namespace Vocaluxe.Menu.SongMenu
{
base.Update(SongOptions);
UpdateList(_Offset);
if (SongOptions.Selection.RandomOnly)
{
_Locked = _PreviewSelected;
@@ -382,6 +384,7 @@ namespace Vocaluxe.Menu.SongMenu
if ((MouseEvent.RB) && (_Base.Songs.GetNumCategories() > 0) && _Base.Songs.GetCurrentCategoryIndex() >= 0 && _Base.Songs.GetTabs() == EOffOn.TR_CONFIG_ON && SongOptions.Selection.CategoryChangeAllowed)
{
ShowCategories();
MouseEvent.Handled = true;
return;
}
else if (MouseEvent.RB && _Base.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !SongOptions.Selection.PartyMode)
@@ -402,6 +405,7 @@ namespace Vocaluxe.Menu.SongMenu
if ((tile.Texture.index != _CoverTexture.index) && CHelper.IsInBounds(tile.Rect, MouseEvent))
{
EnterCategory(_PreviewSelected);
MouseEvent.Handled = true;
return;
}
}
@@ -662,6 +666,7 @@ namespace Vocaluxe.Menu.SongMenu
_Locked = -1;
_actualSelection = 0;
AfterCategoryChange();
_Locked = 0;
}
protected override void ShowCategories()
@@ -672,16 +677,15 @@ namespace Vocaluxe.Menu.SongMenu
_Locked = -1;
_actualSelection = 0;
AfterCategoryChange();
_Locked = 0;
}
private void NextCategory()
{
if (_Base.Songs.GetCurrentCategoryIndex() > -1)
{
Reset();
_Base.Songs.NextCategory();
EnterCategory(_Base.Songs.GetCurrentCategoryIndex());
_Locked = 0;
}
}
@@ -689,10 +693,8 @@ namespace Vocaluxe.Menu.SongMenu
{
if (_Base.Songs.GetCurrentCategoryIndex() > -1)
{
Reset();
_Base.Songs.PrevCategory();
EnterCategory(_Base.Songs.GetCurrentCategoryIndex());
_Locked = 0;
}
}
@@ -827,7 +829,6 @@ namespace Vocaluxe.Menu.SongMenu
}
UpdateList(_Offset);
}
public override bool IsSmallView()
+8
View File
@@ -67,6 +67,14 @@ namespace Vocaluxe.PartyModes
return new ScreenSongOptions();
}
public virtual void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions)
{
}
public virtual void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions)
{
}
public virtual int GetMaxPlayer()
{
return 6;
+1
View File
@@ -16,6 +16,7 @@ namespace Vocaluxe.PartyModes
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
_ScreenSongOptions.Selection.NumJokers = null;
_ScreenSongOptions.Selection.TeamNames = null;
_ScreenSongOptions.Selection.SongIndex = -1;
_ScreenSongOptions.Sorting.SearchString = String.Empty;
_ScreenSongOptions.Sorting.SearchStringVisible = false;
+13
View File
@@ -28,6 +28,16 @@ namespace Vocaluxe.PartyModes
/// </summary>
public struct SelectionOptions
{
/// <summary>
/// If != -1, the SongMenu should set the song selection on the provided song index (visible index) if possible
/// </summary>
public int SongIndex;
/// <summary>
/// If true, the SongMenu should perform the select random song method
/// </summary>
public bool SelectNextRandomSong;
/// <summary>
/// Choosing song only by random
/// </summary>
@@ -69,6 +79,9 @@ namespace Vocaluxe.PartyModes
EScreens GetMainScreen();
ScreenSongOptions GetScreenSongOptions();
void OnSongChange(int SongIndex, ref ScreenSongOptions ScreenSongOptions);
void OnCategoryChange(int CategoryIndex, ref ScreenSongOptions ScreenSongOptions);
int GetMaxPlayer();
int GetMinPlayer();
int GetMaxTeams();