Apply R# clean-up for reliability (#877)

* Apply R# clean-up for reliability

- Migrate to NUnit4 Assert.That
- Update dependencise versions
- Fix LangVersion to 9.0 (until net core migration)
- Reformat code
- Apply 'var' style (easier for refactoring)
- Remove redundant parentheses
- Add braces on every condition blocks (1 line)
- Uses new null checking patterns
- Uses AutoProperties when possible
- Uses string scalar type instead of class
- Clean usings
- Add .orig files in git ignore
- Rename some properties to respect defined conventions and US format definition
	- ID -> Id
	- BPM -> Bpm
	- Finish -> End

* Update R# settings according to the clean-up made
This commit is contained in:
Quentin Bray authored and GitHub committed 2026-06-22 19:52:06 +02:00
1 parent b9b0f7c8df
commit 6ffa63b923
236 files changed
+14194 -7278

No files matched your search

@@ -17,12 +17,10 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Runtime.InteropServices;
using VocaluxeLib.Game;
using VocaluxeLib.Menu;
using VocaluxeLib.Songs;
using VocaluxeLib.Utils;
[assembly: ComVisible(false)]
@@ -30,7 +28,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
public class CRound
{
public int[] SongIDs;
public int[] SongIds;
public int SingerTeam1;
public int SingerTeam2;
public int PointsTeam1;
@@ -90,7 +88,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public readonly EGameMode[] AvailableGameModes = { EGameMode.TR_GAMEMODE_NORMAL, EGameMode.TR_GAMEMODE_SHORTSONG, EGameMode.TR_GAMEMODE_DUET };
private enum EStage
private enum EStage
{
Config,
Songs,
@@ -106,13 +104,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public int NumFields;
public int NumJockers;
public int Team;
public List<Guid> ProfileIDsTeam1;
public List<Guid> ProfileIDsTeam2;
public List<Guid> ProfileIdsTeam1;
public List<Guid> ProfileIdsTeam2;
public ESongSource SongSource;
public ESongSorting Sorting;
public int CategoryIndex;
public int PlaylistID;
public int PlaylistId;
public EGameMode GameMode;
public int NumMedleySongs;
@@ -137,35 +135,35 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ScreenSongOptions.Selection.RandomOnly = false;
_ScreenSongOptions.Selection.PartyMode = true;
_ScreenSongOptions.Selection.CategoryChangeAllowed = true;
_ScreenSongOptions.Selection.NumJokers = new int[] {5, 5};
_ScreenSongOptions.Selection.TeamNames = new string[] {"foo", "bar"};
_ScreenSongOptions.Selection.NumJokers = new int[] { 5, 5 };
_ScreenSongOptions.Selection.TeamNames = new string[] { "foo", "bar" };
_ScreenSongOptions.Sorting.SearchString = String.Empty;
_ScreenSongOptions.Sorting.SearchString = string.Empty;
_ScreenSongOptions.Sorting.SearchActive = false;
_ScreenSongOptions.Sorting.DuetOptions = EDuetOptions.NoDuets;
GameData = new SData
{
NumPlayerTeam1 = 2,
NumPlayerTeam2 = 2,
NumFields = 9,
NumJockers = 1,
ProfileIDsTeam1 = new List<Guid>(),
ProfileIDsTeam2 = new List<Guid>(),
CurrentRoundNr = 0,
FieldNr = 0,
Sorting = CBase.Config.GetSongSorting(),
SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS,
PlaylistID = 0,
CategoryIndex = 0,
GameMode = EGameMode.TR_GAMEMODE_NORMAL,
NumMedleySongs = 5,
Rounds = new List<CRound>(),
Songs = new List<int>(),
NumJokerRandom = new int[2],
NumJokerRetry = new int[2],
RefillJokers = EOffOn.TR_CONFIG_OFF
};
{
NumPlayerTeam1 = 2,
NumPlayerTeam2 = 2,
NumFields = 9,
NumJockers = 1,
ProfileIdsTeam1 = new List<Guid>(),
ProfileIdsTeam2 = new List<Guid>(),
CurrentRoundNr = 0,
FieldNr = 0,
Sorting = CBase.Config.GetSongSorting(),
SongSource = ESongSource.TR_SONGSOURCE_ALLSONGS,
PlaylistId = 0,
CategoryIndex = 0,
GameMode = EGameMode.TR_GAMEMODE_NORMAL,
NumMedleySongs = 5,
Rounds = new List<CRound>(),
Songs = new List<int>(),
NumJokerRandom = new int[2],
NumJokerRetry = new int[2],
RefillJokers = EOffOn.TR_CONFIG_OFF
};
}
public override void SetDefaults()
@@ -178,7 +176,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ScreenSongOptions.Selection.SongIndex = -1;
if (CBase.Config.GetTabs() == EOffOn.TR_CONFIG_ON && _ScreenSongOptions.Sorting.SongSorting != ESongSorting.TR_CONFIG_NONE)
{
_ScreenSongOptions.Sorting.Tabs = EOffOn.TR_CONFIG_ON;
}
GameData.Songs.Clear();
GameData.Rounds.Clear();
@@ -187,7 +187,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override bool Init()
{
if (!base.Init())
{
return false;
}
SetDefaults();
return true;
@@ -224,7 +226,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FadeToScreen()
{
if (CBase.Graphics.GetNextScreen() != _GetNextScreen())
{
CBase.Graphics.FadeTo(_GetNextScreen());
}
}
public void Next()
@@ -253,11 +257,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Stage = EStage.Main;
GameData.Team = GameData.Team == 1 ? 0 : 1;
if (GameData.RefillJokers == EOffOn.TR_CONFIG_ON)
{
_SetNumJokers();
}
break;
default:
throw new ArgumentException("Invalid stage: " + _Stage);
}
_FadeToScreen();
}
@@ -280,6 +288,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
default: // Rest is not allowed
throw new ArgumentException("Invalid stage: " + _Stage);
}
_FadeToScreen();
}
@@ -308,16 +317,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
throw new ArgumentException("Not required!");
}
public override void JokerUsed(int teamNr) {}
public override void JokerUsed(int teamNr) { }
public override void SongSelected(int songID)
public override void SongSelected(int songId)
{
throw new ArgumentException("Not required!");
}
public override void LeavingHighscore()
{
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(0).ID);
CBase.Songs.AddPartySongSung(CBase.Game.GetSong(0).Id);
_UpdateScores();
Next();
}
@@ -325,7 +334,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _CreateRounds()
{
GameData.Rounds = new List<CRound>();
for (int i = 0; i < GameData.NumFields; i++)
for (var i = 0; i < GameData.NumFields; i++)
{
var r = new CRound();
GameData.Rounds.Add(r);
@@ -335,33 +344,39 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public void UpdateSongList()
{
if (GameData.Songs.Count > 0)
{
return;
}
switch (GameData.SongSource)
{
case ESongSource.TR_SONGSOURCE_PLAYLIST:
for (int i = 0; i < CBase.Playlist.GetSongCount(GameData.PlaylistID); i++)
for (var i = 0; i < CBase.Playlist.GetSongCount(GameData.PlaylistId); i++)
{
int id = CBase.Playlist.GetSong(GameData.PlaylistID, i).SongID;
if (CBase.Songs.GetSongByID(id).AvailableGameModes.Contains(GameData.GameMode))
var id = CBase.Playlist.GetSong(GameData.PlaylistId, i).SongId;
if (CBase.Songs.GetSongById(id).IsGameModeAvailable(GameData.GameMode))
{
GameData.Songs.Add(id);
}
}
break;
case ESongSource.TR_SONGSOURCE_ALLSONGS:
ReadOnlyCollection<CSong> avSongs = CBase.Songs.GetSongs();
GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(GameData.GameMode)).Select(song => song.ID));
var avSongs = CBase.Songs.GetSongs();
GameData.Songs.AddRange(avSongs.Where(song => song.IsGameModeAvailable(GameData.GameMode)).Select(song => song.Id));
break;
case ESongSource.TR_SONGSOURCE_CATEGORY:
CBase.Songs.SortSongs(GameData.Sorting, EOffOn.TR_CONFIG_ON, CBase.Config.GetIgnoreArticles(), "", EDuetOptions.All, -1);
CBase.Songs.SetCategory(GameData.CategoryIndex);
avSongs = CBase.Songs.GetVisibleSongs();
GameData.Songs.AddRange(avSongs.Where(song => song.AvailableGameModes.Contains(GameData.GameMode)).Select(song => song.ID));
GameData.Songs.AddRange(avSongs.Where(song => song.IsGameModeAvailable(GameData.GameMode)).Select(song => song.Id));
CBase.Songs.SetCategory(-1);
break;
}
GameData.Songs.Shuffle();
}
@@ -372,32 +387,37 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CBase.Game.SetNumPlayer(2);
SPlayer[] players = CBase.Game.GetPlayers();
var players = CBase.Game.GetPlayers();
if (players == null)
{
return;
}
if (players.Length < 2)
{
return;
}
CRound round = GameData.Rounds[roundNr];
var round = GameData.Rounds[roundNr];
for (int i = 0; i < 2; i++)
for (var i = 0; i < 2; i++)
{
//default values
players[i].ProfileID = Guid.Empty;
players[i].ProfileId = Guid.Empty;
}
//try to fill with the right data
players[0].ProfileID = GameData.ProfileIDsTeam1[round.SingerTeam1];
players[1].ProfileID = GameData.ProfileIDsTeam2[round.SingerTeam2];
players[0].ProfileId = GameData.ProfileIdsTeam1[round.SingerTeam1];
players[1].ProfileId = GameData.ProfileIdsTeam2[round.SingerTeam2];
foreach(int song in round.SongIDs)
foreach (var song in round.SongIds)
{
CBase.Game.AddSong(song, GameData.GameMode);
}
}
private void _SetNumJokers()
{
GameData.NumJokerRandom[0] = GameData.NumJockers;
GameData.NumJokerRandom[1] = GameData.NumJockers;
@@ -423,19 +443,23 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateScores()
{
if (!GameData.Rounds[GameData.FieldNr].Finished)
{
GameData.CurrentRoundNr++;
}
CPoints points = CBase.Game.GetPoints();
SPlayer[] results = CBase.Game.GetPlayers();
var points = CBase.Game.GetPoints();
var results = CBase.Game.GetPlayers();
if (results == null || results.Length < 2)
{
return;
}
//Sum up all points
for (int r = 0; r < points.NumRounds; r++)
for (var r = 0; r < points.NumRounds; r++)
{
SPlayer[] player = points.GetPlayer(r, 2);
for (int i = 0; i < 2; i++)
var player = points.GetPlayer(r, 2);
for (var i = 0; i < 2; i++)
{
results[i].Points += player[i].Points;
results[i].PointsGoldenNotes += player[i].PointsGoldenNotes;
@@ -444,7 +468,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
}
//Calc average of points
for (int i = 0; i < 2; i++)
for (var i = 0; i < 2; i++)
{
results[i].Points /= points.NumRounds;
results[i].PointsGoldenNotes /= points.NumRounds;
@@ -456,9 +480,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
GameData.Rounds[GameData.FieldNr].PointsTeam2 = (int)Math.Round(results[1].Points);
GameData.Rounds[GameData.FieldNr].Finished = true;
if (GameData.Rounds[GameData.FieldNr].PointsTeam1 < GameData.Rounds[GameData.FieldNr].PointsTeam2)
{
GameData.Rounds[GameData.FieldNr].Winner = 2;
}
else if (GameData.Rounds[GameData.FieldNr].PointsTeam1 > GameData.Rounds[GameData.FieldNr].PointsTeam2)
{
GameData.Rounds[GameData.FieldNr].Winner = 1;
}
else
{
GameData.Rounds[GameData.FieldNr].Finished = false;
@@ -16,11 +16,8 @@
#endregion
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Songs;
namespace VocaluxeLib.PartyModes.TicTacToe
{
@@ -71,10 +68,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateSlides();
if (_Buttons[_ButtonBack].Selected)
{
_PartyMode.Back();
}
if (_Buttons[_ButtonNext].Selected)
{
_PartyMode.Next();
}
break;
case Keys.Left:
@@ -86,6 +88,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
break;
}
}
return true;
}
@@ -97,14 +100,20 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
_UpdateSlides();
if (_Buttons[_ButtonBack].Selected)
{
_PartyMode.Back();
}
if (_Buttons[_ButtonNext].Selected)
{
_PartyMode.Next();
}
}
if (mouseEvent.RB)
{
_PartyMode.Back();
}
return true;
}
@@ -135,8 +144,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SelectSlides[_SelectSlideNumFields].SelectedTag = _PartyMode.GameData.NumFields;
_SelectSlides[_SelectSlideNumJockers].Clear();
for (int i = 0; i <= 3; i++)
for (var i = 0; i <= 3; i++)
{
_SelectSlides[_SelectSlideNumJockers].AddValue(i);
}
_SelectSlides[_SelectSlideNumJockers].SelectedTag = _PartyMode.GameData.NumJockers;
@@ -17,10 +17,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Menu;
using VocaluxeLib.Songs;
namespace VocaluxeLib.PartyModes.TicTacToe
{
@@ -71,7 +69,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private const string _StaticTeam2 = "StaticTeam2";
private readonly string[] _EqualizerTeam = new string[]
{"EqualizerTeam1", "EqualizerTeam2"};
{ "EqualizerTeam1", "EqualizerTeam2" };
private bool _ExitPopupVisible;
@@ -97,12 +95,12 @@ namespace VocaluxeLib.PartyModes.TicTacToe
base.Init();
_ThemeTexts = new string[]
{_TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2};
{ _TextPopupReallyExit, _TextTeamChoosing, _TextFinishMessage, _TextNextPlayerT1, _TextNextPlayerT2, _TextNextPlayerNameT1, _TextNextPlayerNameT2 };
_ThemeButtons = new string[]
{
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
_ButtonJokerRetryT2, _ButtonSwitchPlayerT1, _ButtonSwitchPlayerT2
};
{
_ButtonNextRound, _ButtonBack, _ButtonExit, _ButtonPopupYes, _ButtonPopupNo, _ButtonField, _ButtonJokerRandomT1, _ButtonJokerRandomT2, _ButtonJokerRetryT1,
_ButtonJokerRetryT2, _ButtonSwitchPlayerT1, _ButtonSwitchPlayerT2
};
_ThemeStatics = new string[] { _StaticPopupBG, _StaticAvatarT1, _StaticAvatarT2, _StaticTeam1, _StaticTeam2 };
var texts = new List<string>();
@@ -135,28 +133,48 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (!_ExitPopupVisible)
{
if (_PartyMode.GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
{
_Back();
}
else if (_Status == EStatus.None)
{
_EndParty();
}
else
{
_ShowPopup(true);
}
}
else
{
_ShowPopup(false);
}
break;
case Keys.Enter:
if (!_ExitPopupVisible)
{
if (_Buttons[_ButtonNextRound].Selected)
{
_NextRound();
}
if (_Buttons[_ButtonBack].Selected && _PartyMode.GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
{
_Back();
}
if (_Buttons[_ButtonExit].Selected && (_PartyMode.GameData.CurrentRoundNr > 1 || _Status == EStatus.FieldSelected) && _Status != EStatus.None)
{
_ShowPopup(true);
}
else if (_Status == EStatus.None)
{
_EndParty();
for (int i = 0; i < _PartyMode.GameData.NumFields; i++)
}
for (var i = 0; i < _PartyMode.GameData.NumFields; i++)
{
switch (_Status)
{
@@ -166,6 +184,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PartyMode.GameData.FieldNr = i;
_FieldSelected();
}
break;
case EStatus.JokerRetry:
@@ -174,35 +193,61 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PartyMode.GameData.FieldNr = i;
_FieldSelectedAgain();
}
break;
}
}
if (_Status == EStatus.FieldSelected)
{
if (_Buttons[_ButtonJokerRandomT1].Selected)
{
_UseJoker(0, 0);
}
if (_Buttons[_ButtonJokerRandomT2].Selected)
{
_UseJoker(1, 0);
}
if (_Buttons[_ButtonJokerRetryT1].Selected)
{
_UseJoker(0, 1);
}
if (_Buttons[_ButtonJokerRetryT2].Selected)
{
_UseJoker(1, 1);
}
if (_Buttons[_ButtonSwitchPlayerT1].Selected)
{
_ChangePlayer(0, true);
}
if (_Buttons[_ButtonSwitchPlayerT2].Selected)
{
_ChangePlayer(1, true);
}
}
}
else
{
if (_Buttons[_ButtonPopupYes].Selected)
{
_EndParty();
}
if (_Buttons[_ButtonPopupNo].Selected)
{
_ShowPopup(false);
}
}
break;
}
}
return true;
}
@@ -215,17 +260,28 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (!_ExitPopupVisible)
{
if (_Buttons[_ButtonNextRound].Selected)
{
_NextRound();
}
if (_Buttons[_ButtonBack].Selected)
{
_Back();
}
if (_Buttons[_ButtonExit].Selected)
{
if (_Status == EStatus.None)
{
_EndParty();
}
else
{
_ShowPopup(true);
}
}
for (int i = 0; i < _PartyMode.GameData.NumFields; i++)
for (var i = 0; i < _PartyMode.GameData.NumFields; i++)
{
switch (_Status)
{
@@ -235,6 +291,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PartyMode.GameData.FieldNr = i;
_FieldSelected();
}
break;
case EStatus.JokerRetry:
@@ -243,31 +300,55 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PartyMode.GameData.FieldNr = i;
_FieldSelectedAgain();
}
break;
}
}
if (_Status == EStatus.FieldSelected)
{
if (_Buttons[_ButtonJokerRandomT1].Selected)
{
_UseJoker(0, 0);
}
if (_Buttons[_ButtonJokerRandomT2].Selected)
{
_UseJoker(1, 0);
}
if (_Buttons[_ButtonJokerRetryT1].Selected)
{
_UseJoker(0, 1);
}
if (_Buttons[_ButtonJokerRetryT2].Selected)
{
_UseJoker(1, 1);
}
if (_Buttons[_ButtonSwitchPlayerT1].Selected)
{
_ChangePlayer(0, true);
}
if (_Buttons[_ButtonSwitchPlayerT2].Selected)
{
_ChangePlayer(1, true);
}
}
}
else
{
if (_Buttons[_ButtonPopupYes].Selected)
{
_EndParty();
}
if (_Buttons[_ButtonPopupNo].Selected)
{
_ShowPopup(false);
}
}
}
@@ -276,14 +357,22 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (!_ExitPopupVisible)
{
if (_PartyMode.GameData.CurrentRoundNr == 1 && _Status != EStatus.FieldSelected)
{
_Back();
}
else if (_Status == EStatus.None)
{
_EndParty();
}
else
{
_ShowPopup(true);
}
}
else
{
_ShowPopup(false);
}
}
if (mouseEvent.Wheel != 0) { }
@@ -322,7 +411,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateFields();
_UpdateFieldContents();
int winner = _GetWinner();
var winner = _GetWinner();
if (_PartyMode.GameData.CurrentRoundNr <= _PartyMode.GameData.NumFields && winner == 0)
{
_UpdateTeamChoosingMessage();
@@ -354,14 +443,15 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (winner > 0)
{
_Texts[_TextFinishMessage].Color = CBase.Themes.GetPlayerColor(winner);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", PartyModeID) + " " +
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", PartyModeId) + " " + CBase.Language.Translate("TR_TEAM", PartyModeId) + " " +
winner;
}
else
{
_Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", PartyModeID);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", PartyModeId);
}
_SelectElement(_Buttons[_ButtonExit]);
}
@@ -371,9 +461,11 @@ namespace VocaluxeLib.PartyModes.TicTacToe
public override bool UpdateGame()
{
if (!_Equalizers[_EqualizerTeam[0]].Visible)
{
return true;
}
for (int i = 0; i < 2; i++)
for (var i = 0; i < 2; i++)
{
CBase.Record.AnalyzeBuffer(i);
_Equalizers["EqualizerTeam" + (i + 1)].Update(CBase.Record.ToneWeigth(i), CBase.Record.GetMaxVolume(i));
@@ -384,9 +476,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _CreateFields()
{
for (int i = 0; i < 25; i++)
for (var i = 0; i < 25; i++)
{
CButton f = GetNewButton(_Buttons[_ButtonField]);
var f = GetNewButton(_Buttons[_ButtonField]);
f.Visible = false;
_AddButton(f);
_Fields.Add(f);
@@ -396,16 +488,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateFields()
{
var numOneRow = (int)Math.Sqrt(_PartyMode.GameData.NumFields);
float fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
float fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
var fieldSizeY = ((float)CBase.Settings.GetRenderH() - 150 - numOneRow * _FieldSpace) / numOneRow;
var fieldSizeX = ((float)CBase.Settings.GetRenderW() - 300 - numOneRow * _FieldSpace) / numOneRow;
_FieldSize = Math.Min(fieldSizeX, fieldSizeY);
_FieldFirstX = (float)CBase.Settings.GetRenderW() / 2 - (numOneRow * _FieldSize + (numOneRow - 1) * _FieldSpace) / 2;
_FieldFirstY = 140 + (CBase.Settings.GetRenderH() - 140) / 2 - (numOneRow * _FieldSize + numOneRow * _FieldSpace) / 2;
int row = 0;
int column = 0;
float x = _FieldFirstX;
float y = _FieldFirstY;
for (int i = 0; i < _Fields.Count; i++)
var row = 0;
var column = 0;
var x = _FieldFirstX;
var y = _FieldFirstY;
for (var i = 0; i < _Fields.Count; i++)
{
if (i < _PartyMode.GameData.NumFields)
{
@@ -416,7 +508,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Fields[i].Visible = true;
_Fields[i].Selectable = true;
column++;
if ((i + 1) >= numOneRow * (row + 1))
if (i + 1 >= numOneRow * (row + 1))
{
column = 0;
row++;
@@ -424,7 +516,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
x = _FieldFirstX;
}
else
{
x = _FieldFirstX + _FieldSize * column + _FieldSpace * column;
}
}
else
{
@@ -436,7 +530,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateFieldContents()
{
for (int i = 0; i < _PartyMode.GameData.Rounds.Count; i++)
for (var i = 0; i < _PartyMode.GameData.Rounds.Count; i++)
{
_Fields[i].Selectable = true;
_Fields[i].Texture = _Buttons[_ButtonField].Texture;
@@ -445,26 +539,34 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_PartyMode.GameData.Rounds[i].Finished)
{
_Fields[i].Selectable = false;
_Fields[i].Texture = CBase.Songs.GetSongByID(_PartyMode.GameData.Rounds[i].SongIDs[0]).CoverTextureBig;
_Fields[i].Texture = CBase.Songs.GetSongById(_PartyMode.GameData.Rounds[i].SongIds[0]).CoverTextureBig;
_Fields[i].Color = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Rounds[i].Winner);
_Fields[i].SelColor = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Rounds[i].Winner);
}
if (_Status == EStatus.FieldSelected && _PartyMode.GameData.FieldNr == i)
{
_Fields[i].Texture = CBase.Songs.GetSongByID(_PartyMode.GameData.Rounds[i].SongIDs[0]).CoverTextureBig;
_Fields[i].Texture = CBase.Songs.GetSongById(_PartyMode.GameData.Rounds[i].SongIds[0]).CoverTextureBig;
_Fields[i].Color = new SColorF(1, 1, 1, 1);
_Fields[i].SelColor = new SColorF(1, 1, 1, 1);
_Fields[i].Selectable = false;
}
if (_Status == EStatus.JokerRetry && _PartyMode.GameData.Rounds[i].Finished)
{
_Fields[i].SelColor = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Team + 1);
_Fields[i].Selectable = true;
}
if (_Status == EStatus.JokerRetry && !_PartyMode.GameData.Rounds[i].Finished)
{
_Fields[i].Selectable = false;
}
if (_Status == EStatus.FieldSelected)
{
_Fields[i].Selectable = false;
}
}
}
@@ -474,17 +576,18 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
_ChangePlayer();
}
_PartyMode.UpdateSongList();
int[] songIDs = new int[_PartyMode.GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY ? _PartyMode.GameData.NumMedleySongs : 1];
for (int i = 0; i < songIDs.Length; i++)
var songIds = new int[_PartyMode.GameData.GameMode == EGameMode.TR_GAMEMODE_MEDLEY ? _PartyMode.GameData.NumMedleySongs : 1];
for (var i = 0; i < songIds.Length; i++)
{
songIDs[i] = _PartyMode.GameData.Songs[0];
songIds[i] = _PartyMode.GameData.Songs[0];
_PartyMode.GameData.Songs.RemoveAt(0);
}
_StartPreview(songIDs[0]);
_StartPreview(songIds[0]);
_Status = EStatus.FieldSelected;
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIDs = songIDs;
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIds = songIds;
_UpdateFieldContents();
_UpdateJokerButtons();
_UpdateSwitchPlayerButtons();
@@ -498,10 +601,10 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _FieldSelectedAgain()
{
int[] songIDs = _PartyMode.GameData.Rounds[_OldSelectedField].SongIDs;
_StartPreview(songIDs[0]);
var songIds = _PartyMode.GameData.Rounds[_OldSelectedField].SongIds;
_StartPreview(songIds[0]);
_Status = EStatus.FieldSelected;
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIDs = songIDs;
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SongIds = songIds;
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam1;
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2 = _PartyMode.GameData.Rounds[_OldSelectedField].SingerTeam2;
_UpdateFieldContents();
@@ -516,32 +619,31 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SelectElement(_Buttons[_ButtonNextRound]);
}
private void _StartPreview(int songID)
private void _StartPreview(int songId)
{
CSong song = CBase.Songs.GetSongByID(songID);
var song = CBase.Songs.GetSongById(songId);
CBase.BackgroundMusic.LoadPreview(song);
}
private int _GetRamdom(int max)
{
lock (syncLock)
{
return random.Next(max+1);
{
return random.Next(max + 1);
}
}
private void _ChangePlayer(int teamNr = -1, bool next = false)
{
if (_PartyMode.GameData.ProfileIDsTeam1.Count > 0 && (teamNr == 0 || teamNr == -1))
if (_PartyMode.GameData.ProfileIdsTeam1.Count > 0 && (teamNr == 0 || teamNr == -1))
{
idPlayer1 = _GetTeamPlayer(idPlayer1, _PartyMode.GameData.ProfileIDsTeam1.Count, next);
idPlayer1 = _GetTeamPlayer(idPlayer1, _PartyMode.GameData.ProfileIdsTeam1.Count, next);
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1 = idPlayer1;
}
if (_PartyMode.GameData.ProfileIDsTeam2.Count > 0 && (teamNr == 1 || teamNr == -1))
if (_PartyMode.GameData.ProfileIdsTeam2.Count > 0 && (teamNr == 1 || teamNr == -1))
{
idPlayer2 = _GetTeamPlayer(idPlayer2, _PartyMode.GameData.ProfileIDsTeam2.Count, next);
idPlayer2 = _GetTeamPlayer(idPlayer2, _PartyMode.GameData.ProfileIdsTeam2.Count, next);
_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2 = idPlayer2;
}
@@ -553,15 +655,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (next)
{
idPlayer++;
if (idPlayer >= _PartyMode.GameData.ProfileIDsTeam1.Count)
if (idPlayer >= _PartyMode.GameData.ProfileIdsTeam1.Count)
{
idPlayer = 0;
}
}
else
{
idPlayer = _GetRamdom(_PartyMode.GameData.ProfileIDsTeam1.Count - 1);
idPlayer = _GetRamdom(_PartyMode.GameData.ProfileIdsTeam1.Count - 1);
}
return idPlayer;
}
@@ -572,13 +675,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Texts[_TextNextPlayerNameT1].Visible = true;
_Texts[_TextNextPlayerNameT2].Visible = true;
_Texts[_TextNextPlayerNameT1].Text =
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIdsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
_Texts[_TextNextPlayerNameT2].Text =
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
CBase.Profiles.GetPlayerName(_PartyMode.GameData.ProfileIdsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
_Statics[_StaticAvatarT1].Visible = true;
_Statics[_StaticAvatarT2].Visible = true;
_Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
_Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIDsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
_Statics[_StaticAvatarT1].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIdsTeam1[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam1]);
_Statics[_StaticAvatarT2].Texture = CBase.Profiles.GetAvatar(_PartyMode.GameData.ProfileIdsTeam2[_PartyMode.GameData.Rounds[_PartyMode.GameData.FieldNr].SingerTeam2]);
_Statics[_StaticTeam1].Visible = true;
_Statics[_StaticTeam2].Visible = true;
_Equalizers[_EqualizerTeam[0]].Visible = true;
@@ -596,6 +699,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PartyMode.GameData.NumJokerRandom[teamNr]--;
_FieldSelected(true);
}
break;
//Retry-Joker
@@ -610,20 +714,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_UpdateFieldContents();
_Buttons[_ButtonNextRound].Visible = false;
}
break;
}
_UpdateJokerButtons();
}
private void _UpdateTeamChoosingMessage()
{
_Texts[_TextTeamChoosing].Color = CBase.Themes.GetPlayerColor(_PartyMode.GameData.Team + 1);
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", PartyModeID) + " " + (_PartyMode.GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", PartyModeID);
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", PartyModeId) + " " + (_PartyMode.GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", PartyModeId);
if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing)
{
_Texts[_TextTeamChoosing].Visible = true;
}
else
{
_Texts[_TextTeamChoosing].Visible = false;
}
}
private void _UpdateJokerButtons()
@@ -649,7 +759,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Buttons[_ButtonSwitchPlayerT1].Visible = true;
_Buttons[_ButtonSwitchPlayerT2].Visible = true;
}
}
private void _NextRound()
@@ -672,7 +781,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Buttons[_ButtonPopupNo].Visible = _ExitPopupVisible;
if (_ExitPopupVisible)
{
_SelectElement(_Buttons[_ButtonPopupNo]);
}
}
private void _Back()
@@ -683,51 +794,71 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _BuildWinnerPossibilities()
{
var numOneRow = (int)Math.Sqrt(_PartyMode.GameData.NumFields);
_Possibilities = new int[(numOneRow * 2) + 2, numOneRow];
for (int i = 0; i < _Possibilities.GetLength(0); i++)
_Possibilities = new int[numOneRow * 2 + 2, numOneRow];
for (var i = 0; i < _Possibilities.GetLength(0); i++)
{
if (i < numOneRow)
{
for (int c = 0; c < numOneRow; c++)
for (var c = 0; c < numOneRow; c++)
{
_Possibilities[i, c] = i * numOneRow + c;
}
}
else if (i < numOneRow * 2)
{
for (int c = 0; c < numOneRow; c++)
_Possibilities[i, c] = (i - numOneRow) + (c * numOneRow);
for (var c = 0; c < numOneRow; c++)
{
_Possibilities[i, c] = i - numOneRow + c * numOneRow;
}
}
else if (i == _Possibilities.GetLength(0) - 2)
{
for (int c = 0; c < numOneRow; c++)
for (var c = 0; c < numOneRow; c++)
{
_Possibilities[i, c] = (numOneRow + 1) * c;
}
}
else if (i == _Possibilities.GetLength(0) - 1)
{
for (int c = 0; c < numOneRow; c++)
for (var c = 0; c < numOneRow; c++)
{
_Possibilities[i, c] = (numOneRow - 1) * c + (numOneRow - 1);
}
}
}
}
private int _GetWinner()
{
for (int i = 0; i < _Possibilities.GetLength(0); i++)
for (var i = 0; i < _Possibilities.GetLength(0); i++)
{
var check = new List<int>();
for (int j = 0; j < _Possibilities.GetLength(1); j++)
for (var j = 0; j < _Possibilities.GetLength(1); j++)
{
if (_PartyMode.GameData.Rounds[_Possibilities[i, j]].Winner > 0)
{
check.Add(_PartyMode.GameData.Rounds[_Possibilities[i, j]].Winner);
}
}
if (check.Count != _Possibilities.GetLength(1))
{
continue;
}
//Check for winner
if (check.Contains(1) && !check.Contains(2))
{
return 1;
}
if (check.Contains(2) && !check.Contains(1))
{
return 2;
}
}
return 0;
}
}
}
}
@@ -17,14 +17,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe
{
// ReSharper disable UnusedMember.Global
public class CPartyScreenTicTacToeNames : CMenuPartyNameSelection
// ReSharper restore UnusedMember.Global
// ReSharper restore UnusedMember.Global
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
protected override int _ScreenVersion
@@ -44,14 +43,19 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
base.OnShow();
while (_PartyMode.GameData.ProfileIDsTeam1.Count > _PartyMode.GameData.NumPlayerTeam1)
_PartyMode.GameData.ProfileIDsTeam1.RemoveAt(_PartyMode.GameData.ProfileIDsTeam1.Count - 1);
while (_PartyMode.GameData.ProfileIDsTeam2.Count > _PartyMode.GameData.NumPlayerTeam2)
_PartyMode.GameData.ProfileIDsTeam2.RemoveAt(_PartyMode.GameData.ProfileIDsTeam2.Count - 1);
while (_PartyMode.GameData.ProfileIdsTeam1.Count > _PartyMode.GameData.NumPlayerTeam1)
{
_PartyMode.GameData.ProfileIdsTeam1.RemoveAt(_PartyMode.GameData.ProfileIdsTeam1.Count - 1);
}
while (_PartyMode.GameData.ProfileIdsTeam2.Count > _PartyMode.GameData.NumPlayerTeam2)
{
_PartyMode.GameData.ProfileIdsTeam2.RemoveAt(_PartyMode.GameData.ProfileIdsTeam2.Count - 1);
}
SetPartyModeData(2, _PartyMode.GameData.NumPlayerTeam1 + _PartyMode.GameData.NumPlayerTeam2,
new int[] {_PartyMode.GameData.NumPlayerTeam1, _PartyMode.GameData.NumPlayerTeam2});
List<Guid>[] ids = new List<Guid>[] {_PartyMode.GameData.ProfileIDsTeam1, _PartyMode.GameData.ProfileIDsTeam2};
new int[] { _PartyMode.GameData.NumPlayerTeam1, _PartyMode.GameData.NumPlayerTeam2 });
var ids = new List<Guid>[] { _PartyMode.GameData.ProfileIdsTeam1, _PartyMode.GameData.ProfileIdsTeam2 };
SetPartyModeProfiles(ids);
}
@@ -59,14 +63,16 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
if (_TeamList.Length == 2)
{
_PartyMode.GameData.ProfileIDsTeam1 = _TeamList[0];
_PartyMode.GameData.ProfileIDsTeam2 = _TeamList[1];
_PartyMode.GameData.ProfileIdsTeam1 = _TeamList[0];
_PartyMode.GameData.ProfileIdsTeam2 = _TeamList[1];
}
if (_NumPlayerTeams.Length == 2)
{
_PartyMode.GameData.NumPlayerTeam1 = _NumPlayerTeams[0];
_PartyMode.GameData.NumPlayerTeam2 = _NumPlayerTeams[1];
}
_PartyMode.Back();
}
@@ -74,13 +80,14 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
if (_TeamList.Length == 2)
{
_PartyMode.GameData.ProfileIDsTeam1 = _TeamList[0];
_PartyMode.GameData.ProfileIDsTeam2 = _TeamList[1];
_PartyMode.GameData.ProfileIdsTeam1 = _TeamList[0];
_PartyMode.GameData.ProfileIdsTeam2 = _TeamList[1];
}
_PartyMode.GameData.NumPlayerTeam1 = _PartyMode.GameData.ProfileIDsTeam1.Count;
_PartyMode.GameData.NumPlayerTeam2 = _PartyMode.GameData.ProfileIDsTeam2.Count;
_PartyMode.GameData.NumPlayerTeam1 = _PartyMode.GameData.ProfileIdsTeam1.Count;
_PartyMode.GameData.NumPlayerTeam2 = _PartyMode.GameData.ProfileIdsTeam2.Count;
_PartyMode.Next();
}
}
}
}
@@ -15,7 +15,6 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System.Collections.Generic;
using VocaluxeLib.Menu;
namespace VocaluxeLib.PartyModes.TicTacToe
@@ -40,7 +39,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
Source = _PartyMode.GameData.SongSource;
Sorting = _PartyMode.GameData.Sorting;
Category = _PartyMode.GameData.CategoryIndex;
Playlist = _PartyMode.GameData.PlaylistID;
Playlist = _PartyMode.GameData.PlaylistId;
SongMode = _PartyMode.GameData.GameMode;
NumMedleySongs = _PartyMode.GameData.NumMedleySongs;
@@ -76,9 +75,9 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_PartyMode.GameData.SongSource = Source;
_PartyMode.GameData.Sorting = Sorting;
_PartyMode.GameData.CategoryIndex = Category;
_PartyMode.GameData.PlaylistID = Playlist;
_PartyMode.GameData.PlaylistId = Playlist;
_PartyMode.GameData.GameMode = SongMode;
_PartyMode.GameData.NumMedleySongs = NumMedleySongs;
}
}
}
}
@@ -27,6 +27,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<CodeAnalysisRuleSet>..\..\CheckingRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWin|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -40,6 +41,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
<DebugSymbols>true</DebugSymbols>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -52,6 +54,7 @@
<WarningLevel>4</WarningLevel>
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseLinux|AnyCPU'">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -65,6 +68,7 @@
<GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies>
<Prefer32Bit>false</Prefer32Bit>
<DebugSymbols>true</DebugSymbols>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerWin|AnyCPU'">
<OutputPath>bin</OutputPath>
@@ -78,6 +82,7 @@
<Prefer32Bit>false</Prefer32Bit>
<DebugType>pdbonly</DebugType>
<DebugSymbols>true</DebugSymbols>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup>
<Compile Include="CPartyScreenTicTacToeSongs.cs" />
@@ -119,4 +124,4 @@ rm -f "$(SolutionDir)Output\PartyModes\$(TargetName)\Code\GlobalSuppressions.cs"
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>