Used object initializers

This commit is contained in:
Flamefire committed 2013-04-23 22:11:32 +02:00
1 parent 477b023520
commit b8fe334153
47 files changed
+289 -515

No files matched your search

@@ -178,14 +178,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain();
_GameData = new SData();
_GameData.NumPlayer = 4;
_GameData.NumPlayerAtOnce = 2;
_GameData.NumRounds = 2;
_GameData.CurrentRoundNr = 1;
_GameData.ProfileIDs = new List<int>();
_GameData.CatSongIndices = null;
_GameData.Results = null;
_GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List<int>(), CatSongIndices = null, Results = null};
}
public override bool Init()
@@ -657,15 +650,11 @@ namespace VocaluxeLib.PartyModes.Challenge
List<SStats> result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{
SStats stat = new SStats();
stat.ProfileID = results[i].ProfileID;
stat.SingPoints = (int)Math.Round(results[i].Points);
stat.Won = 0;
stat.GamePoints = 0;
SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
result.Add(stat);
}
result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints));
int current = result[result.Count - 1].SingPoints;
int points = result.Count;
@@ -53,10 +53,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig();
config.NumPlayer = 4;
config.NumPlayerAtOnce = 2;
config.NumRounds = 12;
SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12};
_Data.ScreenConfig = config;
}
@@ -227,10 +224,7 @@ namespace VocaluxeLib.PartyModes.Challenge
int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce;
int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce;
if (mod == 0)
_RoundSteps = res;
else
_RoundSteps = _Data.ScreenConfig.NumPlayer;
_RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer;
}
private void _Back()
@@ -98,8 +98,7 @@ namespace VocaluxeLib.PartyModes.Challenge
public CPartyScreenChallengeMain()
{
_Data = new SDataFromScreen();
_Data.ScreenMain = new SFromScreenMain();
_Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()};
}
public override void Init()
@@ -406,9 +405,7 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++)
{
CRoundsTableRow rtr = new CRoundsTableRow();
rtr.TextPlayer = new List<CText>();
rtr.TextScores = new List<CText>();
CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
_RoundsTable.Add(rtr);
}
//Create statics and texts for rounds
@@ -438,11 +435,8 @@ namespace VocaluxeLib.PartyModes.Challenge
{
_RoundsTableScrollArea = new SRectF();
int numPlayerInOneRow = 3;
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow)
_NumRoundsVisible = 5;
else
_NumRoundsVisible = 3;
const int numPlayerInOneRow = 3;
_NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
if (_NumRoundsVisible > _GameState.Combs.Count)
_NumRoundsVisible = _GameState.Combs.Count;
@@ -536,10 +530,7 @@ namespace VocaluxeLib.PartyModes.Challenge
private void _BuildPlayerTable()
{
_PlayerTableScrollArea = new SRectF();
_PlayerTableScrollArea.X = _Texts[_TextPosition].X;
_PlayerTableScrollArea.Y = _Texts[_TextPosition].Y;
_PlayerTableScrollArea.W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X;
_PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
_PlayerTable = new List<STableRow>();
float delta = _Texts[_TextPosition].Height * 1.2f;
@@ -548,14 +539,15 @@ namespace VocaluxeLib.PartyModes.Challenge
for (int i = 0; i < 10; i++)
{
STableRow row = new STableRow();
row.Pos = GetNewText(_Texts[_TextPosition]);
row.Name = GetNewText(_Texts[_TextPlayerName]);
row.Rounds = GetNewText(_Texts[_TextNumPlayed]);
row.Won = GetNewText(_Texts[_TextWon]);
row.SingPoints = GetNewText(_Texts[_TextSingPoints]);
row.GamePoints = GetNewText(_Texts[_TextGamePoints]);
STableRow row = new STableRow
{
Pos = GetNewText(_Texts[_TextPosition]),
Name = GetNewText(_Texts[_TextPlayerName]),
Rounds = GetNewText(_Texts[_TextNumPlayed]),
Won = GetNewText(_Texts[_TextWon]),
SingPoints = GetNewText(_Texts[_TextSingPoints]),
GamePoints = GetNewText(_Texts[_TextGamePoints])
};
row.Pos.Y += delta * (i + 1);
row.Name.Y += delta * (i + 1);
@@ -182,14 +182,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain();
_GameData = new SData();
_GameData.NumPlayer = 4;
_GameData.NumPlayerAtOnce = 2;
_GameData.NumRounds = 2;
_GameData.CurrentRoundNr = 1;
_GameData.ProfileIDs = new List<int>();
_GameData.CatSongIndices = null;
_GameData.Results = null;
_GameData = new SData {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 2, CurrentRoundNr = 1, ProfileIDs = new List<int>(), CatSongIndices = null, Results = null};
}
public override bool Init()
@@ -637,13 +630,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
for (int i = 0; i < _GameData.NumPlayer; i++)
{
CResultTableRow row = new CResultTableRow();
row.PlayerID = _GameData.ProfileIDs[i];
row.NumPlayed = 0;
row.NumRounds = 0;
row.NumWon = 0;
row.NumSingPoints = 0;
row.NumGamePoints = 0;
CResultTableRow row = new CResultTableRow {PlayerID = _GameData.ProfileIDs[i], NumPlayed = 0, NumRounds = 0, NumWon = 0, NumSingPoints = 0, NumGamePoints = 0};
_GameData.ResultTable.Add(row);
}
@@ -732,15 +719,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
List<SStats> result = new List<SStats>();
for (int i = 0; i < _GameData.NumPlayerAtOnce; i++)
{
SStats stat = new SStats();
stat.ProfileID = results[i].ProfileID;
stat.SingPoints = (int)Math.Round(results[i].Points);
stat.Won = 0;
stat.GamePoints = 0;
SStats stat = new SStats {ProfileID = results[i].ProfileID, SingPoints = (int)Math.Round(results[i].Points), Won = 0, GamePoints = 0};
result.Add(stat);
}
result.Sort(delegate(SStats s1, SStats s2) { return s1.SingPoints.CompareTo(s2.SingPoints); });
result.Sort((s1, s2) => s1.SingPoints.CompareTo(s2.SingPoints));
int current = result[result.Count - 1].SingPoints;
int points = result.Count;
@@ -53,10 +53,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ThemeButtons = new string[] {_ButtonNext, _ButtonBack};
_Data = new SDataFromScreen();
SFromScreenConfig config = new SFromScreenConfig();
config.NumPlayer = 4;
config.NumPlayerAtOnce = 2;
config.NumRounds = 12;
SFromScreenConfig config = new SFromScreenConfig {NumPlayer = 4, NumPlayerAtOnce = 2, NumRounds = 12};
_Data.ScreenConfig = config;
}
@@ -227,10 +224,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
int res = _Data.ScreenConfig.NumPlayer / _Data.ScreenConfig.NumPlayerAtOnce;
int mod = _Data.ScreenConfig.NumPlayer % _Data.ScreenConfig.NumPlayerAtOnce;
if (mod == 0)
_RoundSteps = res;
else
_RoundSteps = _Data.ScreenConfig.NumPlayer;
_RoundSteps = mod == 0 ? res : _Data.ScreenConfig.NumPlayer;
}
private void _Back()
@@ -98,8 +98,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
public CPartyScreenChallengeMedleyMain()
{
_Data = new SDataFromScreen();
_Data.ScreenMain = new SFromScreenMain();
_Data = new SDataFromScreen {ScreenMain = new SFromScreenMain()};
}
public override void Init()
@@ -406,9 +405,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable = new List<CRoundsTableRow>();
for (int i = 0; i < 5; i++)
{
CRoundsTableRow rtr = new CRoundsTableRow();
rtr.TextPlayer = new List<CText>();
rtr.TextScores = new List<CText>();
CRoundsTableRow rtr = new CRoundsTableRow {TextPlayer = new List<CText>(), TextScores = new List<CText>()};
_RoundsTable.Add(rtr);
}
//Create statics and texts for rounds
@@ -438,11 +435,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
{
_RoundsTableScrollArea = new SRectF();
int numPlayerInOneRow = 3;
if (_GameState.NumPlayerAtOnce <= numPlayerInOneRow)
_NumRoundsVisible = 5;
else
_NumRoundsVisible = 3;
const int numPlayerInOneRow = 3;
_NumRoundsVisible = _GameState.NumPlayerAtOnce <= numPlayerInOneRow ? 5 : 3;
if (_NumRoundsVisible > _GameState.Combs.Count)
_NumRoundsVisible = _GameState.Combs.Count;
@@ -536,10 +530,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private void _BuildPlayerTable()
{
_PlayerTableScrollArea = new SRectF();
_PlayerTableScrollArea.X = _Texts[_TextPosition].X;
_PlayerTableScrollArea.Y = _Texts[_TextPosition].Y;
_PlayerTableScrollArea.W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X;
_PlayerTableScrollArea = new SRectF {X = _Texts[_TextPosition].X, Y = _Texts[_TextPosition].Y, W = _Texts[_TextGamePoints].X - _Texts[_TextPosition].X};
_PlayerTable = new List<STableRow>();
float delta = _Texts[_TextPosition].Height * 1.2f;
@@ -548,14 +539,15 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
for (int i = 0; i < 10; i++)
{
STableRow row = new STableRow();
row.Pos = GetNewText(_Texts[_TextPosition]);
row.Name = GetNewText(_Texts[_TextPlayerName]);
row.Rounds = GetNewText(_Texts[_TextNumPlayed]);
row.Won = GetNewText(_Texts[_TextWon]);
row.SingPoints = GetNewText(_Texts[_TextSingPoints]);
row.GamePoints = GetNewText(_Texts[_TextGamePoints]);
STableRow row = new STableRow
{
Pos = GetNewText(_Texts[_TextPosition]),
Name = GetNewText(_Texts[_TextPlayerName]),
Rounds = GetNewText(_Texts[_TextNumPlayed]),
Won = GetNewText(_Texts[_TextWon]),
SingPoints = GetNewText(_Texts[_TextSingPoints]),
GamePoints = GetNewText(_Texts[_TextGamePoints])
};
row.Pos.Y += delta * (i + 1);
row.Name.Y += delta * (i + 1);
@@ -88,10 +88,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames();
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDs = new List<int>();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDs = new List<int>()};
_Data.ScreenNames = names;
}
@@ -316,9 +313,7 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton();
pcb.Button = b;
pcb.ProfileID = -1;
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
_PlayerChooseButtons.Add(pcb);
column++;
if (column >= _PlayerChooseButtonsNumH)
@@ -203,24 +203,26 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ToScreenNames = new SDataToScreenNames();
_ToScreenMain = new SDataToScreenMain();
_GameData = new SData();
_GameData.NumFields = 9;
_GameData.NumPlayerTeam1 = 2;
_GameData.NumPlayerTeam2 = 2;
_GameData.ProfileIDsTeam1 = new List<int>();
_GameData.ProfileIDsTeam2 = new List<int>();
_GameData.PlayerTeam1 = new List<int>();
_GameData.PlayerTeam2 = new List<int>();
_GameData.CurrentRoundNr = 0;
_GameData.SingRoundNr = 0;
_GameData.SongSource = ESongSource.TR_ALLSONGS;
_GameData.PlaylistID = 0;
_GameData.CategoryID = 0;
_GameData.GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL;
_GameData.Rounds = new List<CRound>();
_GameData.Songs = new List<int>();
_GameData.NumJokerRandom = new int[2];
_GameData.NumJokerRetry = new int[2];
_GameData = new SData
{
NumFields = 9,
NumPlayerTeam1 = 2,
NumPlayerTeam2 = 2,
ProfileIDsTeam1 = new List<int>(),
ProfileIDsTeam2 = new List<int>(),
PlayerTeam1 = new List<int>(),
PlayerTeam2 = new List<int>(),
CurrentRoundNr = 0,
SingRoundNr = 0,
SongSource = ESongSource.TR_ALLSONGS,
PlaylistID = 0,
CategoryID = 0,
GameMode = EPartyGameMode.TR_GAMEMODE_NORMAL,
Rounds = new List<CRound>(),
Songs = new List<int>(),
NumJokerRandom = new int[2],
NumJokerRetry = new int[2]
};
}
public override bool Init()
@@ -281,10 +283,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Stage = EStage.NotStarted;
else
{
if (CBase.Game.GetRandom(100) < 50)
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.Team = CBase.Game.GetRandom(100) < 50 ? 0 : 1;
_GameData.ProfileIDsTeam1 = dataFrom.ScreenNames.ProfileIDsTeam1;
_GameData.ProfileIDsTeam2 = dataFrom.ScreenNames.ProfileIDsTeam2;
_Stage = EStage.Names;
@@ -377,10 +376,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
if (screen != null)
{
if (_GameData.Team == 1)
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.Team = _GameData.Team == 1 ? 0 : 1;
CBase.Songs.ResetPartySongSung();
_GameData.CurrentRoundNr = 1;
_ToScreenMain.CurrentRoundNr = 1;
@@ -410,10 +406,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Screens.TryGetValue("CPartyScreenTicTacToeMain", out screen);
if (screen != null)
{
if (_GameData.Team == 1)
_GameData.Team = 0;
else
_GameData.Team = 1;
_GameData.Team = _GameData.Team == 1 ? 0 : 1;
_UpdateSongList();
_UpdatePlayerList();
_ToScreenMain.CurrentRoundNr = _GameData.CurrentRoundNr;
@@ -388,8 +388,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
{
for (int i = 0; i < 25; i++)
{
CField f = new CField();
f.Button = GetNewButton(_Buttons[_ButtonField]);
CField f = new CField {Button = GetNewButton(_Buttons[_ButtonField])};
f.Button.Visible = false;
f.Content = new CRound();
_AddButton(f.Button);
@@ -93,11 +93,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown};
_Data = new SDataFromScreen();
SFromScreenNames names = new SFromScreenNames();
names.FadeToConfig = false;
names.FadeToMain = false;
names.ProfileIDsTeam1 = new List<int>();
names.ProfileIDsTeam2 = new List<int>();
SFromScreenNames names = new SFromScreenNames {FadeToConfig = false, FadeToMain = false, ProfileIDsTeam1 = new List<int>(), ProfileIDsTeam2 = new List<int>()};
_Data.ScreenNames = names;
}
@@ -378,9 +374,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
CButton b = GetNewButton(_Buttons[_ButtonPlayerChoose]);
b.Rect.X = _PlayerChooseButtonsFirstX + column * (b.Rect.W + _PlayerChooseButtonsSpaceH);
b.Rect.Y = _PlayerChooseButtonsFirstY + row * (b.Rect.H + _PlayerChooseButtonsSpaceW);
CPlayerChooseButton pcb = new CPlayerChooseButton();
pcb.Button = b;
pcb.ProfileID = -1;
CPlayerChooseButton pcb = new CPlayerChooseButton {Button = b, ProfileID = -1};
_PlayerChooseButtons.Add(pcb);
column++;
if (column >= _PlayerChooseButtonsNumH)