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);