Refactor PartyModes in preparation for a more unified name selection and maybe config
This commit is contained in:
1 parent
29dccbd8ae
commit
84e9163b96
22 files changed
+386
-426
No files matched your search
@@ -149,7 +149,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
|
||||
resetSelection = true;
|
||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
|
||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
|
||||
resetSelection = true;
|
||||
}
|
||||
else if (!_SelectingFast)
|
||||
@@ -346,9 +346,9 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (numPressed > 0)
|
||||
{
|
||||
if (_ChangeTeamNumDynamic && numPressed < _PartyMode.GetMaxTeams() && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
|
||||
if (_ChangeTeamNumDynamic && numPressed < _PartyMode.MaxTeams && numPressed > _SelectSlides[_SelectSlideTeams].NumValues)
|
||||
{
|
||||
while (numPressed < _PartyMode.GetMaxTeams())
|
||||
while (numPressed < _PartyMode.MaxTeams)
|
||||
IncreaseTeamNum();
|
||||
}
|
||||
if (numPressed <= _SelectSlides[_SelectSlideTeams].NumValues)
|
||||
@@ -435,7 +435,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
|
||||
stopSelectingFast = true;
|
||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
|
||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
|
||||
stopSelectingFast = true;
|
||||
}
|
||||
else
|
||||
@@ -507,7 +507,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (!_ChangePlayerNumDynamic && _TeamList[_CurrentTeam].Count == _NumPlayerTeams[_CurrentTeam])
|
||||
stopSelectingFast = true;
|
||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.GetMaxPlayerPerTeam())
|
||||
else if (_TeamList[_CurrentTeam].Count == _PartyMode.MaxPlayersPerTeam)
|
||||
stopSelectingFast = true;
|
||||
}
|
||||
else if (mouseEvent.MB)
|
||||
@@ -573,7 +573,7 @@ namespace VocaluxeLib.Menu
|
||||
if (!_AllowChangeTeamNum)
|
||||
return;
|
||||
|
||||
if (_NumTeams + 1 <= _PartyMode.GetMaxTeams())
|
||||
if (_NumTeams + 1 <= _PartyMode.MaxTeams)
|
||||
{
|
||||
_NumTeams++;
|
||||
int[] numPlayerTeams = _NumPlayerTeams;
|
||||
@@ -602,7 +602,7 @@ namespace VocaluxeLib.Menu
|
||||
if (!_AllowChangeTeamNum)
|
||||
return;
|
||||
|
||||
if (_NumTeams - 1 >= _PartyMode.GetMinTeams())
|
||||
if (_NumTeams - 1 >= _PartyMode.MinTeams)
|
||||
_NumTeams--;
|
||||
_UpdateButtonState();
|
||||
}
|
||||
@@ -613,7 +613,7 @@ namespace VocaluxeLib.Menu
|
||||
return;
|
||||
if (_NumPlayerTeams.Length > team)
|
||||
{
|
||||
if (_NumPlayerTeams[team] + 1 <= _PartyMode.GetMaxPlayerPerTeam())
|
||||
if (_NumPlayerTeams[team] + 1 <= _PartyMode.MaxPlayersPerTeam)
|
||||
_NumPlayerTeams[team]++;
|
||||
_UpdatePlayerSlide();
|
||||
}
|
||||
@@ -626,7 +626,7 @@ namespace VocaluxeLib.Menu
|
||||
return;
|
||||
if (_NumPlayerTeams.Length > team)
|
||||
{
|
||||
if (_NumPlayerTeams[team] - 1 >= _PartyMode.GetMinPlayerPerTeam())
|
||||
if (_NumPlayerTeams[team] - 1 >= _PartyMode.MinPlayersPerTeam)
|
||||
_NumPlayerTeams[team]--;
|
||||
if (_TeamList[team].Count > _NumPlayerTeams[team])
|
||||
_RemovePlayerByIndex(team, _NumPlayerTeams[team] - 1);
|
||||
@@ -699,20 +699,20 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
private void _UpdateButtonVisibility()
|
||||
{
|
||||
_Buttons[_ButtonIncreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
|
||||
_Buttons[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.GetMinTeams() != _PartyMode.GetMaxTeams();
|
||||
_Buttons[_ButtonIncreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.MinTeams != _PartyMode.MaxTeams;
|
||||
_Buttons[_ButtonDecreaseTeams].Visible = _AllowChangePlayerNum && _Teams && _PartyMode.MinTeams != _PartyMode.MaxTeams;
|
||||
_Buttons[_ButtonIncreasePlayer].Visible = _AllowChangePlayerNum;
|
||||
_Buttons[_ButtonDecreasePlayer].Visible = _AllowChangePlayerNum;
|
||||
}
|
||||
|
||||
private void _UpdateButtonState()
|
||||
{
|
||||
_Buttons[_ButtonIncreaseTeams].Selectable = _NumTeams < _PartyMode.GetMaxTeams();
|
||||
_Buttons[_ButtonDecreaseTeams].Selectable = _NumTeams > _PartyMode.GetMinTeams();
|
||||
_Buttons[_ButtonIncreaseTeams].Selectable = _NumTeams < _PartyMode.MaxTeams;
|
||||
_Buttons[_ButtonDecreaseTeams].Selectable = _NumTeams > _PartyMode.MinTeams;
|
||||
if (_NumPlayerTeams != null && _NumPlayerTeams.Length > _CurrentTeam)
|
||||
{
|
||||
_Buttons[_ButtonIncreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] < _PartyMode.GetMaxPlayerPerTeam();
|
||||
_Buttons[_ButtonDecreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] > _PartyMode.GetMinPlayerPerTeam();
|
||||
_Buttons[_ButtonIncreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] < _PartyMode.MaxPlayersPerTeam;
|
||||
_Buttons[_ButtonDecreasePlayer].Selectable = _NumPlayerTeams[_CurrentTeam] > _PartyMode.MinPlayersPerTeam;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -725,7 +725,7 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
if (_NumPlayerTeams[team] == _TeamList[team].Count && !_ChangePlayerNumDynamic)
|
||||
return;
|
||||
if (_NumPlayerTeams[team] == _PartyMode.GetMaxPlayerPerTeam())
|
||||
if (_NumPlayerTeams[team] == _PartyMode.MaxPlayersPerTeam)
|
||||
return;
|
||||
|
||||
_NameSelections[_NameSelection].UseProfile(profileID);
|
||||
|
||||
@@ -390,6 +390,15 @@ namespace VocaluxeLib.Menu
|
||||
_NeedsRevalidate = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an integer to the slide setting its tag to the value and its text to the text representation of the tag
|
||||
/// </summary>
|
||||
/// <param name="tag">Value to add</param>
|
||||
public void AddValue(int tag)
|
||||
{
|
||||
AddValue(tag.ToString(), null, tag);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds an entry to the slide.
|
||||
/// </summary>
|
||||
@@ -434,6 +443,17 @@ namespace VocaluxeLib.Menu
|
||||
AddValue(values[i], textures[i]);
|
||||
}
|
||||
|
||||
public void RemoveValue(string text)
|
||||
{
|
||||
int idx = _Values.FindIndex(val => val.Text == text);
|
||||
if (idx < 0)
|
||||
return;
|
||||
_Values.RemoveAt(idx);
|
||||
if (Selection >= idx)
|
||||
Selection--;
|
||||
_Invalidate();
|
||||
}
|
||||
|
||||
public void SetValues<T>(int selection)
|
||||
{
|
||||
AddValues(Enum.GetNames(typeof(T)));
|
||||
|
||||
Reference in new issue
Block a user