More refactoring (unused stuff removed)

This commit is contained in:
Flamefire committed 2013-04-23 21:47:46 +02:00
1 parent ec766aa7b5
commit 477b023520
38 files changed
+217 -350

No files matched your search

+1 -1
View File
@@ -1844,7 +1844,7 @@
<!--<Font>: Text font name-->
<Font>Outline</Font>
<!--<Text>: Nothing or translation tag-->
<Text />
<Text>%a - %t</Text>
<!--<Reflection> If exists:-->
<!-- <Space>: Reflection Space-->
<!-- <Height>: Reflection Height-->
@@ -643,13 +643,12 @@ namespace VocaluxeLib.PartyModes.Challenge
int pos = 1;
int lastPoints = 0;
int lastSingPoints = 0;
for (int i = 0; i < _GameData.ResultTable.Count; i++)
{
if (lastPoints > _GameData.ResultTable[i].NumGamePoints || lastSingPoints > _GameData.ResultTable[i].NumSingPoints)
foreach (CResultTableRow resultRow in _GameData.ResultTable) {
if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints)
pos++;
_GameData.ResultTable[i].Position = pos;
lastPoints = _GameData.ResultTable[i].NumGamePoints;
lastSingPoints = _GameData.ResultTable[i].NumSingPoints;
resultRow.Position = pos;
lastPoints = resultRow.NumGamePoints;
lastSingPoints = resultRow.NumSingPoints;
}
}
@@ -412,12 +412,11 @@ namespace VocaluxeLib.PartyModes.Challenge
_RoundsTable.Add(rtr);
}
//Create statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++)
{
foreach (CRoundsTableRow roundRow in _RoundsTable) {
//Round-number
CText text = GetNewText(_Texts[_TextRoundNumber]);
_AddText(text);
_RoundsTable[round].Number = text;
roundRow.Number = text;
for (int row = 0; row < 2; row++)
{
for (int column = 0; column < 3; column++)
@@ -425,11 +424,11 @@ namespace VocaluxeLib.PartyModes.Challenge
//Player
text = GetNewText(_Texts[_TextRoundPlayer]);
_AddText(text);
_RoundsTable[round].TextPlayer.Add(text);
roundRow.TextPlayer.Add(text);
//Score
text = GetNewText(_Texts[_TextRoundScore]);
_AddText(text);
_RoundsTable[round].TextScores.Add(text);
roundRow.TextScores.Add(text);
}
}
}
@@ -458,11 +457,10 @@ namespace VocaluxeLib.PartyModes.Challenge
float delta = _Texts[_TextRoundNumber].Height;
//Update statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++)
{
foreach (CRoundsTableRow roundRow in _RoundsTable) {
//Round-number
_RoundsTable[round].Number.X = numberX;
_RoundsTable[round].Number.Y = numberY;
roundRow.Number.X = numberX;
roundRow.Number.Y = numberY;
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
for (int row = 0; row < numInnerRows; row++)
{
@@ -479,14 +477,14 @@ namespace VocaluxeLib.PartyModes.Challenge
float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
_RoundsTable[round].TextPlayer[column].X = x;
_RoundsTable[round].TextPlayer[column].Y = numberY;
_RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
roundRow.TextPlayer[column].X = x;
roundRow.TextPlayer[column].Y = numberY;
roundRow.TextPlayer[column].MaxWidth = maxw;
//Score
_RoundsTable[round].TextScores[column] = _RoundsTable[round].TextScores[column];
_RoundsTable[round].TextScores[column].X = x;
_RoundsTable[round].TextScores[column].Y = numberY + delta;
_RoundsTable[round].TextScores[column].MaxWidth = maxw;
roundRow.TextScores[column] = roundRow.TextScores[column];
roundRow.TextScores[column].X = x;
roundRow.TextScores[column].Y = numberY + delta;
roundRow.TextScores[column].MaxWidth = maxw;
}
numberY = numberY + delta + delta;
}
@@ -155,8 +155,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
if (_Combs.Count == 0)
_Create();
CCombination combs = new CCombination();
if (_NumPlayer == _NumMics)
return _Combs[0];
@@ -718,13 +718,12 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
int pos = 1;
int lastPoints = 0;
int lastSingPoints = 0;
for (int i = 0; i < _GameData.ResultTable.Count; i++)
{
if (lastPoints > _GameData.ResultTable[i].NumGamePoints || lastSingPoints > _GameData.ResultTable[i].NumSingPoints)
foreach (CResultTableRow resultRow in _GameData.ResultTable) {
if (lastPoints > resultRow.NumGamePoints || lastSingPoints > resultRow.NumSingPoints)
pos++;
_GameData.ResultTable[i].Position = pos;
lastPoints = _GameData.ResultTable[i].NumGamePoints;
lastSingPoints = _GameData.ResultTable[i].NumSingPoints;
resultRow.Position = pos;
lastPoints = resultRow.NumGamePoints;
lastSingPoints = resultRow.NumSingPoints;
}
}
@@ -412,12 +412,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_RoundsTable.Add(rtr);
}
//Create statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++)
{
foreach (CRoundsTableRow roundRow in _RoundsTable) {
//Round-number
CText text = GetNewText(_Texts[_TextRoundNumber]);
_AddText(text);
_RoundsTable[round].Number = text;
roundRow.Number = text;
for (int row = 0; row < 2; row++)
{
for (int column = 0; column < 3; column++)
@@ -425,11 +424,11 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
//Player
text = GetNewText(_Texts[_TextRoundPlayer]);
_AddText(text);
_RoundsTable[round].TextPlayer.Add(text);
roundRow.TextPlayer.Add(text);
//Score
text = GetNewText(_Texts[_TextRoundScore]);
_AddText(text);
_RoundsTable[round].TextScores.Add(text);
roundRow.TextScores.Add(text);
}
}
}
@@ -458,11 +457,10 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
float delta = _Texts[_TextRoundNumber].Height;
//Update statics and texts for rounds
for (int round = 0; round < _RoundsTable.Count; round++)
{
foreach (CRoundsTableRow roundRow in _RoundsTable) {
//Round-number
_RoundsTable[round].Number.X = numberX;
_RoundsTable[round].Number.Y = numberY;
roundRow.Number.X = numberX;
roundRow.Number.Y = numberY;
int numInnerRows = (int)Math.Ceiling(_GameState.NumPlayerAtOnce / ((double)numPlayerInOneRow));
for (int row = 0; row < numInnerRows; row++)
{
@@ -479,14 +477,14 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
float x = numberX + 15 + (CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow * (column - row * numPlayerInOneRow) +
((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2;
float maxw = ((CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20) / numPlayerInThisRow) / 2 - 5;
_RoundsTable[round].TextPlayer[column].X = x;
_RoundsTable[round].TextPlayer[column].Y = numberY;
_RoundsTable[round].TextPlayer[column].MaxWidth = maxw;
roundRow.TextPlayer[column].X = x;
roundRow.TextPlayer[column].Y = numberY;
roundRow.TextPlayer[column].MaxWidth = maxw;
//Score
_RoundsTable[round].TextScores[column] = _RoundsTable[round].TextScores[column];
_RoundsTable[round].TextScores[column].X = x;
_RoundsTable[round].TextScores[column].Y = numberY + delta;
_RoundsTable[round].TextScores[column].MaxWidth = maxw;
roundRow.TextScores[column] = roundRow.TextScores[column];
roundRow.TextScores[column].X = x;
roundRow.TextScores[column].Y = numberY + delta;
roundRow.TextScores[column].MaxWidth = maxw;
}
numberY = numberY + delta + delta;
}
@@ -85,7 +85,6 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
_Data.ScreenNames.ProfileIDs = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose};
_Data = new SDataFromScreen();
@@ -459,21 +458,20 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley
private bool _OnAdd()
{
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
{
if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1)
foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons) {
if (chooseButton.Button.Selected && chooseButton.ProfileID != -1)
{
if (_Data.ScreenNames.ProfileIDs.Count < _NumPlayer)
{
_Data.ScreenNames.ProfileIDs.Add(_PlayerChooseButtons[i].ProfileID);
_Data.ScreenNames.ProfileIDs.Add(chooseButton.ProfileID);
int added = _Data.ScreenNames.ProfileIDs.Count - 1;
_UpdateButtonNext();
//Update texture and name
_PlayerDestinationButtons[added].Color = new SColorF(1, 1, 1, 0.6f);
_PlayerDestinationButtons[added].SelColor = new SColorF(1, 1, 1, 1);
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[_PlayerChooseButtons[i].ProfileID].PlayerName;
_PlayerDestinationButtons[added].Texture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].SelTexture = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].Avatar.Texture;
_PlayerDestinationButtons[added].Text.Text = CBase.Profiles.GetProfiles()[chooseButton.ProfileID].PlayerName;
_PlayerDestinationButtons[added].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
@@ -90,7 +90,6 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_Data.ScreenNames.ProfileIDsTeam1 = new List<int>();
_Data.ScreenNames.ProfileIDsTeam2 = new List<int>();
List<string> buttons = new List<string>();
_ThemeButtons = new string[] {_ButtonBack, _ButtonNext, _ButtonPlayerDestination, _ButtonPlayerChoose, _ButtonPlayerChooseScrollUp, _ButtonPlayerChooseScrollDown};
_Data = new SDataFromScreen();
@@ -178,18 +177,17 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_OldMouseX = mouseEvent.X;
_OldMouseY = mouseEvent.Y;
//Check if mouse if over tile
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
{
if (_PlayerChooseButtons[i].Button.Selected)
foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons) {
if (chooseButton.Button.Selected)
{
_SelectedPlayerNr = _PlayerChooseButtons[i].ProfileID;
_SelectedPlayerNr = chooseButton.ProfileID;
if (_SelectedPlayerNr != -1)
{
//Activate mouse-selecting
_SelectingMouseActive = true;
//Update of Drag/Drop-Texture
_ChooseAvatarStatic.Visible = true;
_ChooseAvatarStatic.Rect = _PlayerChooseButtons[i].Button.Rect;
_ChooseAvatarStatic.Rect = chooseButton.Button.Rect;
_ChooseAvatarStatic.Rect.Z = -100;
_ChooseAvatarStatic.Color = new SColorF(1, 1, 1, 1);
_ChooseAvatarStatic.Texture = CBase.Profiles.GetProfiles()[_SelectedPlayerNr].Avatar.Texture;
-1
View File
@@ -280,7 +280,6 @@ namespace Vocaluxe.Base
{
if (_PreviousFileNames.Count > 0 && _PreviousMusicIndex >= 0)
{
float pos = CSound.GetPosition(_CurrentMusicStream);
if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f)
{
//Seek to #Start-Tag, if found
+7 -5
View File
@@ -401,7 +401,7 @@ namespace Vocaluxe.Base
{
_CreateOrConvert(oldDBFilePath);
_CreateOrConvert(_HighscoreFilePath);
_ImportData(oldDBFilePath, _HighscoreFilePath);
_ImportData(oldDBFilePath);
File.Delete(oldDBFilePath);
}
@@ -916,7 +916,7 @@ namespace Vocaluxe.Base
return true;
}
private static bool _ImportData(string sourceDBPath, string destinationDBPath)
private static bool _ImportData(string sourceDBPath)
{
#region open db
using (SQLiteConnection connSource = new SQLiteConnection())
@@ -936,11 +936,9 @@ namespace Vocaluxe.Base
using (SQLiteCommand cmdSource = new SQLiteCommand(connSource))
{
SQLiteDataReader source;
#region import table scores
cmdSource.CommandText = "SELECT SongID, PlayerName, Score, LineNr, Date, Medley, Duet, ShortSong, Difficulty FROM Scores";
source = cmdSource.ExecuteReader();
SQLiteDataReader source = cmdSource.ExecuteReader();
if (source == null)
return false;
@@ -1260,6 +1258,7 @@ namespace Vocaluxe.Base
}
//If you want to add an image to db, call this method!
/*
private static bool _AddImageToCreditsDB(String imagePath)
{
bool result = false;
@@ -1333,6 +1332,7 @@ namespace Vocaluxe.Base
return result;
}
*/
private static bool _InitCreditsRessourcesDB()
{
@@ -1388,6 +1388,7 @@ namespace Vocaluxe.Base
return true;
}
/*
private static void _CreateCreditsRessourcesDB()
{
using (SQLiteConnection connection = new SQLiteConnection())
@@ -1422,6 +1423,7 @@ namespace Vocaluxe.Base
}
}
}
*/
#endregion CreditsRessources
private static byte[] _GetBytes(SQLiteDataReader reader)
+17 -18
View File
@@ -273,41 +273,40 @@ namespace Vocaluxe.Base
CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
}
for (int i = 0; i < _PopupScreens.Count; i++)
{
_PopupScreens[i].Init();
_PopupScreens[i].LoadTheme(CTheme.GetThemeScreensPath(-1));
foreach (IMenu popup in _PopupScreens) {
popup.Init();
popup.LoadTheme(CTheme.GetThemeScreensPath(-1));
}
}
public static void ReloadTheme()
{
_ReloadCursor();
for (int i = 0; i < _Screens.Count; i++)
_Screens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
foreach (IMenu screen in _Screens)
screen.ReloadTheme(CTheme.GetThemeScreensPath(-1));
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].ReloadTheme(CTheme.GetThemeScreensPath(-1));
foreach (IMenu popup in _PopupScreens)
popup.ReloadTheme(CTheme.GetThemeScreensPath(-1));
}
public static void ReloadSkin()
{
_ReloadCursor();
for (int i = 0; i < _Screens.Count; i++)
_Screens[i].ReloadTextures();
foreach (IMenu menu in _Screens)
menu.ReloadTextures();
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].ReloadTextures();
foreach (IMenu menu in _PopupScreens)
menu.ReloadTextures();
}
public static void SaveTheme()
{
CTheme.SaveTheme();
for (int i = 0; i < _Screens.Count; i++)
_Screens[i].SaveTheme();
foreach (IMenu screen in _Screens)
screen.SaveTheme();
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].SaveTheme();
foreach (IMenu popup in _PopupScreens)
popup.SaveTheme();
}
public static void InitFirstScreen()
@@ -444,8 +443,8 @@ namespace Vocaluxe.Base
_OldScreen = _Screens[(int)_CurrentScreen];
}
for (int i = 0; i < _PopupScreens.Count; i++)
_PopupScreens[i].Draw();
foreach (IMenu popup in _PopupScreens)
popup.Draw();
_Cursor.Draw();
_DrawDebugInfos();
+1 -6
View File
@@ -108,12 +108,7 @@ namespace Vocaluxe.Base
return -1;
}
public static string Translate(string keyWord)
{
return Translate(keyWord, -1);
}
public static string Translate(string keyWord, int partyModeID)
public static string Translate(string keyWord, int partyModeID = -1)
{
if (keyWord == null)
return "Error";
+21 -21
View File
@@ -100,33 +100,32 @@ namespace Vocaluxe.Base
{
List<SPartyModeInfos> infos = new List<SPartyModeInfos>();
int[] usedKeys = new int[_PartyModes.Count];
_PartyModes.Keys.CopyTo(usedKeys, 0);
int[] pmIDs = new int[_PartyModes.Count];
_PartyModes.Keys.CopyTo(pmIDs, 0);
for (int i = 0; i < usedKeys.Length; i++)
{
if (usedKeys[i] != _NormalGameModeID)
foreach (int pmID in pmIDs) {
if (pmID != _NormalGameModeID)
{
SPartyMode mode;
_PartyModes.TryGetValue(usedKeys[i], out mode);
_PartyModes.TryGetValue(pmID, out mode);
if (mode.PartyMode != null)
{
SPartyModeInfos info = new SPartyModeInfos();
info.Author = mode.Author;
info.Description = mode.Description;
info.Name = mode.Name;
info.PartyModeID = mode.PartyModeID;
info.Playable = mode.NoErrors;
info.VersionMajor = mode.PartyModeVersionMajor;
info.VersionMinor = mode.PartyModeVersionMinor;
info.TargetAudience = mode.TargetAudience;
info.MaxPlayers = mode.PartyMode.GetMaxPlayer();
info.MinPlayers = mode.PartyMode.GetMinPlayer();
info.MaxTeams = mode.PartyMode.GetMaxTeams();
info.MinTeams = mode.PartyMode.GetMinTeams();
SPartyModeInfos info = new SPartyModeInfos
{
Author = mode.Author,
Description = mode.Description,
Name = mode.Name,
PartyModeID = mode.PartyModeID,
Playable = mode.NoErrors,
VersionMajor = mode.PartyModeVersionMajor,
VersionMinor = mode.PartyModeVersionMinor,
TargetAudience = mode.TargetAudience,
MaxPlayers = mode.PartyMode.GetMaxPlayer(),
MinPlayers = mode.PartyMode.GetMinPlayer(),
MaxTeams = mode.PartyMode.GetMaxTeams(),
MinTeams = mode.PartyMode.GetMinTeams()
};
infos.Add(info);
}
@@ -348,6 +347,7 @@ namespace Vocaluxe.Base
CompilerParameters compilerParams = new CompilerParameters();
compilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll");
compilerParams.ReferencedAssemblies.Add("System.Core.dll");
compilerParams.ReferencedAssemblies.Add("VocaluxeLib.dll");
compilerParams.GenerateInMemory = true;
#if DEBUG
+3 -4
View File
@@ -263,11 +263,10 @@ namespace Vocaluxe.Base
string artist = line.Substring(0, pos - 1).Trim();
string title = line.Substring(pos + 1, line.Length - pos - 1).Trim();
bool found = false;
for (int s = 0; s < allSongs.Length; s++)
{
if (allSongs[s].Artist == artist && allSongs[s].Title == title)
foreach (CSong song in allSongs) {
if (song.Artist == artist && song.Title == title)
{
pl.AddSong(allSongs[s].ID);
pl.AddSong(song.ID);
found = true;
break;
}
+2 -2
View File
@@ -35,9 +35,9 @@ namespace Vocaluxe.Base
public bool Visible;
public bool PartyHidden;
public SSongPointer(int iD, string sortString)
public SSongPointer(int id, string sortString)
{
SongID = iD;
SongID = id;
SortString = sortString;
CatIndex = -1;
Visible = false;
+3 -3
View File
@@ -35,7 +35,7 @@ namespace Vocaluxe.Base
#region Playback
private static IPlayback _Playback;
public static bool PlaybackInit()
public static bool Init()
{
switch (CConfig.PlayBackLib)
{
@@ -55,7 +55,7 @@ namespace Vocaluxe.Base
_Playback = new CPortAudioPlay();
break;
}
return true;
return _Playback.Init();
}
public static void SetGlobalVolume(float volume)
@@ -613,7 +613,7 @@ namespace Vocaluxe.Base
float dt = Time;
float diff = _ExternTime.Time - dt;
float diff = et - dt;
if (Math.Abs(diff) > 0.05f)
{
_Timer.Reset();
+5 -5
View File
@@ -96,8 +96,8 @@ namespace Vocaluxe.Lib.Sound
if (!_Initialized)
return false;
for (int i = 0; i < _Buffer.Length; i++)
_Buffer[i].Reset();
foreach (CBuffer buffer in _Buffer)
buffer.Reset();
_DeviceConfig = deviceConfig;
bool[] active = new bool[deviceConfig.Length];
@@ -373,8 +373,8 @@ namespace Vocaluxe.Lib.Sound
if (_Notifications != null)
{
for (int i = 0; i < _Notifications.Count; i++)
_Notifications[i].Event.Close();
foreach (NotificationPosition notification in _Notifications)
notification.Event.Close();
_Notifications.Clear();
_Notifications = null;
@@ -420,7 +420,7 @@ namespace Vocaluxe.Lib.Sound
}
// ReSharper disable InconsistentNaming
protected virtual void Dispose(bool disposing)
protected void Dispose(bool disposing)
// ReSharper restore InconsistentNaming
{
if (disposing)
+2 -5
View File
@@ -28,9 +28,8 @@ namespace Vocaluxe.Lib.Sound
//static float LastPosition;
#region log
public CGstreamerAudioWrapper.LogCallback Log;
private void _LogHandler(string text)
private static void _LogHandler(string text)
{
CLog.LogError(text);
}
@@ -38,11 +37,9 @@ namespace Vocaluxe.Lib.Sound
public CGstreamerAudio()
{
Init();
Log = _LogHandler;
//Is this really needed? CodaAnalyzer complains about it...
//GC.SuppressFinalize(Log);
CGstreamerAudioWrapper.SetLogCallback(Log);
CGstreamerAudioWrapper.SetLogCallback(_LogHandler);
}
public bool Init()
-14
View File
@@ -40,11 +40,6 @@ namespace Vocaluxe.Lib.Sound
private List<SAudioStreams> _Streams;
public COpenALPlay()
{
Init();
}
public bool Init()
{
if (_Initialized)
@@ -335,15 +330,6 @@ namespace Vocaluxe.Lib.Sound
return -1;
}
private void _EndSync(int handle, int stream, int data, IntPtr user)
{
if (_Initialized)
{
if (_AlreadyAdded(stream))
Close(stream);
}
}
private void _CloseProc(int streamID)
{
if (_Initialized)
+2 -20
View File
@@ -21,6 +21,7 @@ using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using Vocaluxe.Base;
@@ -40,11 +41,6 @@ namespace Vocaluxe.Lib.Sound
private List<SAudioStreams> _Streams;
public CPortAudioPlay()
{
Init();
}
public bool Init()
{
if (_Initialized)
@@ -302,12 +298,7 @@ namespace Vocaluxe.Lib.Sound
private bool _AlreadyAdded(int stream)
{
foreach (SAudioStreams st in _Streams)
{
if (st.Handle == stream)
return true;
}
return false;
return _Streams.Any(st => st.Handle == stream);
}
private int _GetStreamIndex(int stream)
@@ -320,15 +311,6 @@ namespace Vocaluxe.Lib.Sound
return -1;
}
private void _EndSync(int handle, int stream, int data, IntPtr user)
{
if (_Initialized)
{
if (_AlreadyAdded(stream))
Close(stream);
}
}
private void _CloseProc(int streamID)
{
if (_Initialized)
+2 -2
View File
@@ -189,8 +189,8 @@ namespace Vocaluxe.Lib.Sound
if (!_Initialized)
return false;
for (int i = 0; i < _RecHandle.Length; i++)
CPortAudio.Pa_StopStream(_RecHandle[i]);
foreach (IntPtr handle in _RecHandle)
CPortAudio.Pa_StopStream(handle);
return true;
}
@@ -38,7 +38,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
public void Init() {}
public void Open(string fileName, bool loop)
public void Open(string fileName)
{
_FileName = fileName;
+1 -1
View File
@@ -31,7 +31,7 @@ namespace Vocaluxe.Lib.Sound.Decoder
void Init();
void Close();
void Open(string fileName, bool loop = false);
void Open(string fileName);
SFormatInfo GetFormatInfo();
float GetLength();
@@ -27,6 +27,7 @@ namespace Vocaluxe.Lib.Sound.PortAudio
PortAudio v.19 bindings for .NET
</summary>
*/
// ReSharper disable UnusedMember.Global
public static class CPortAudio
{
@@ -550,4 +551,6 @@ namespace Vocaluxe.Lib.Sound.PortAudio
public static extern void Pa_Sleep(int msec);
#endregion
}
// ReSharper restore UnusedMember.Global
}
+3 -3
View File
@@ -27,7 +27,7 @@ namespace Vocaluxe.Lib.Video
class CVideoDecoderGstreamer : IVideoDecoder
{
#region log
private CGstreamerVideoWrapper.LogCallback Log;
private CGstreamerVideoWrapper.LogCallback _Log;
private void _LogHandler(string text)
{
@@ -38,10 +38,10 @@ namespace Vocaluxe.Lib.Video
public bool Init()
{
bool retval = CGstreamerVideoWrapper.InitVideo();
Log = _LogHandler;
_Log = _LogHandler;
//Really needed? CodeAnalysis complains
//GC.SuppressFinalize(Log);
CGstreamerVideoWrapper.SetVideoLogCallback(Log);
CGstreamerVideoWrapper.SetVideoLogCallback(_Log);
return retval;
}
+1 -1
View File
@@ -114,7 +114,7 @@ namespace Vocaluxe
// Init Playback
CLog.StartBenchmark(0, "Init Playback");
CSound.PlaybackInit();
CSound.Init();
CLog.StopBenchmark(0, "Init Playback");
Application.DoEvents();
+25 -27
View File
@@ -204,35 +204,33 @@ namespace Vocaluxe.Screens
//Prepare Text
int lastY = 280;
for (int i = 0; i < _Paragraphs.Count; i++)
{
foreach (string[] paragraph in _Paragraphs) {
string line = "";
for (int e = 0; e < _Paragraphs[i].Length; e++)
for (int e = 0; e < paragraph.Length; e++)
{
if (_Paragraphs[i][e] != null)
if (paragraph[e] == null)
continue;
string newLine = " " + paragraph[e];
CText text = GetNewText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
if (CDraw.GetTextBounds(text).Width < (CSettings.RenderW - 220))
{
string newline = line + " " + _Paragraphs[i][e];
CText text = GetNewText(75, lastY, -2, 30, -1, EAlignment.Left, EStyle.Bold, "Outline", new SColorF(1, 1, 1, 1), line);
if (CDraw.GetTextBounds(text).Width < (CSettings.RenderW - 220))
{
line = line + " " + _Paragraphs[i][e];
line += newLine;
//Check if all words are used
if ((e + 1) == _Paragraphs[i].Length)
{
text.Text = line;
_ParagraphTexts.Add(text);
line = "";
lastY += 40;
}
}
else
//Check if all words are used
if ((e + 1) == paragraph.Length)
{
text.Text = line;
_ParagraphTexts.Add(text);
line = " " + _Paragraphs[i][e];
lastY += 27;
line = "";
lastY += 40;
}
}
else
{
_ParagraphTexts.Add(text);
line = newLine;
lastY += 27;
}
}
}
}
@@ -276,7 +274,7 @@ namespace Vocaluxe.Screens
return true;
}
public CParticleEffect GetStarParticles(int numStars, bool isRed, SRectF rect, bool bigParticles)
private CParticleEffect _GetStarParticles(int numStars, bool isRed, SRectF rect, bool bigParticles)
{
SColorF partColor = isRed ? new SColorF(1, 0, 0, 1) : new SColorF(0.149f, 0.415f, 0.819f, 1);
int partSize = bigParticles ? 35 : 25;
@@ -296,7 +294,7 @@ namespace Vocaluxe.Screens
SRectF imgDotRect = new SRectF(particleRect);
imgDotRect.Z = -5;
CStatic imgDot = GetNewStatic(texDot, new SColorF(1, 1, 1, 1), imgDotRect);
CParticleEffect particle = GetStarParticles(partCount, isRight, particleRect, bigParticles);
CParticleEffect particle = _GetStarParticles(partCount, isRight, particleRect, bigParticles);
CCreditName credit = new CCreditName(image, imgDot, particle, particleOffsetX, particleOffsetY);
@@ -324,8 +322,8 @@ namespace Vocaluxe.Screens
//Little stars for logo
int numstars = (int)(_Logo.Rect.W * 0.25f / 2f);
SRectF partRect = new SRectF(_Logo.Rect.X, _Logo.Rect.Y, _Logo.Rect.W, _Logo.Rect.H, -1);
_StarsRed = GetStarParticles(numstars, true, partRect, true);
_StarsBlue = GetStarParticles(numstars, false, partRect, true);
_StarsRed = _GetStarParticles(numstars, true, partRect, true);
_StarsBlue = _GetStarParticles(numstars, false, partRect, true);
//Credit names
_CreditNames = new List<CCreditName>();
@@ -371,8 +369,8 @@ namespace Vocaluxe.Screens
//Draw Text
if (_TextTimer.IsRunning)
{
for (int i = 0; i < _ParagraphTexts.Count; i++)
_ParagraphTexts[i].Draw();
foreach (CText text in _ParagraphTexts)
text.Draw();
}
return true;
}
-1
View File
@@ -257,7 +257,6 @@ namespace Vocaluxe.Screens
{
_IsDuet = false;
CPoints points = CGame.GetPoints();
SPlayer player = points.GetPlayer(_Round, CGame.NumPlayer)[0];
CSong song = CGame.GetSong(_Round + 1);
if (song == null)
return;
+1 -4
View File
@@ -654,10 +654,7 @@ namespace Vocaluxe.Screens
for (int p = 0; p < CGame.NumPlayer; p++)
{
_NoteLines[p] = _SingNotes[_SingBars].AddPlayer(
_SingNotes[_SingBars].BarPos[p, CGame.NumPlayer - 1],
CTheme.GetPlayerColor(p + 1),
p);
_NoteLines[p] = _SingNotes[_SingBars].AddPlayer(_SingNotes[_SingBars].BarPos[p, CGame.NumPlayer - 1],CTheme.GetPlayerColor(p + 1),p);
}
/*
+1 -11
View File
@@ -294,17 +294,7 @@ namespace VocaluxeLib.Menu
return false;
}
public void Draw()
{
Draw(false);
}
public void ForceDraw()
{
Draw(true);
}
public void Draw(bool forceDraw)
public void Draw(bool forceDraw = false)
{
if (!Visible && CBase.Settings.GetGameState() != EGameState.EditTheme && !forceDraw)
return;
+1 -11
View File
@@ -139,17 +139,7 @@ namespace VocaluxeLib.Menu
rect = new RectangleF(left, upper, rigth - left, lower - upper);
}
public static List<string> ListFiles(string path, string cast)
{
return ListFiles(path, cast, false, false);
}
public static List<string> ListFiles(string path, string cast, bool recursive)
{
return ListFiles(path, cast, recursive, false);
}
public static List<string> ListFiles(string path, string cast, bool recursive, bool fullpath)
public static List<string> ListFiles(string path, string cast, bool recursive = false, bool fullpath = false)
{
List<string> files = new List<string>();
DirectoryInfo dir = new DirectoryInfo(path);
-5
View File
@@ -36,11 +36,6 @@ namespace VocaluxeLib.Menu
_PartyModeID = partyModeID;
}
public int GetPartyModeID()
{
return _PartyModeID;
}
public void AssingPartyMode(IPartyMode partyMode)
{
_PartyMode = partyMode;
-10
View File
@@ -244,16 +244,6 @@ namespace VocaluxeLib.Menu
}
public void Draw()
{
Draw(false);
}
public void ForceDraw()
{
Draw(true);
}
public void Draw(bool forceDraw)
{
int i = 0;
foreach (CTile tile in _Tiles)
+2 -12
View File
@@ -412,17 +412,7 @@ namespace VocaluxeLib.Menu
return false;
}
public void Draw()
{
Draw(false);
}
public void ForceDraw()
{
Draw(true);
}
public void Draw(bool forceDraw)
public void Draw(bool forceDraw = false)
{
if (_PlaylistElements.Count <= 0)
LoadPlaylist(0);
@@ -1226,7 +1216,7 @@ namespace VocaluxeLib.Menu
CSong song = CBase.Songs.GetSongByID(pec.SongID);
_PlaylistElements[i].Cover.Texture = song.CoverTextureSmall;
string t1 = _Theme.Text1.Text.Replace("%a", song.Artist).Replace("%t", song.Title);
_PlaylistElements[i].Text1.Text = /*(Offset + i + 1) + ") " + */ song.Artist + " - " + song.Title; //TODO: Add text field for the number
_PlaylistElements[i].Text1.Text = /*(Offset + i + 1) + ") " + */ t1; //TODO: Add text field for the number
_PlaylistElements[i].SelectSlide.Clear();
for (int g = 0; g < pec.Modes.Length; g++)
{
+1 -6
View File
@@ -693,17 +693,12 @@ namespace VocaluxeLib.Menu
CBase.Drawing.DrawColor(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(x, Y, bounds.Width, bounds.Height, Z));
}
public void DrawRelative(float x, float y)
{
DrawRelative(x, y, false, 0f, 0f, 0f);
}
public void DrawRelative(float x, float y, float reflectionSpace, float reflectionHeigth, float rectHeight)
{
DrawRelative(x, y, true, reflectionSpace, reflectionHeigth, rectHeight);
}
public void DrawRelative(float rx, float ry, bool reflection, float reflectionSpace, float reflectionHeight, float rectHeight)
public void DrawRelative(float rx, float ry, bool reflection = false, float reflectionSpace = 0f, float reflectionHeight = 0f, float rectHeight = 0f)
{
// Update Text
Text = Text;
+9 -2
View File
@@ -36,8 +36,7 @@ namespace VocaluxeLib.Menu
{
Mouse,
Keyboard,
WiiMote,
Gamepad
WiiMote
}
#endregion Inputs
@@ -126,7 +125,9 @@ namespace VocaluxeLib.Menu
// ReSharper disable InconsistentNaming
// don't change the order!
TR_CONFIG_OFF, //no debug infos
// ReSharper disable UnusedMember.Global
TR_CONFIG_ONLY_FPS,
// ReSharper restore UnusedMember.Global
TR_CONFIG_LEVEL1,
TR_CONFIG_LEVEL2,
TR_CONFIG_LEVEL3,
@@ -213,7 +214,9 @@ namespace VocaluxeLib.Menu
public enum ECoverLoading
{
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
TR_CONFIG_COVERLOADING_ONDEMAND,
// ReSharper restore UnusedMember.Global
TR_CONFIG_COVERLOADING_ATSTART,
TR_CONFIG_COVERLOADING_DYNAMIC
// ReSharper restore InconsistentNaming
@@ -222,9 +225,11 @@ namespace VocaluxeLib.Menu
public enum EGameDifficulty
{
// ReSharper disable InconsistentNaming
// ReSharper disable UnusedMember.Global
TR_CONFIG_EASY,
TR_CONFIG_NORMAL,
TR_CONFIG_HARD
// ReSharper restore UnusedMember.Global
// ReSharper restore InconsistentNaming
}
@@ -260,7 +265,9 @@ namespace VocaluxeLib.Menu
TR_CONFIG_PLAYERINFO_BOTH,
TR_CONFIG_PLAYERINFO_NAME,
TR_CONFIG_PLAYERINFO_AVATAR,
// ReSharper disable UnusedMember.Global
TR_CONFIG_PLAYERINFO_OFF
// ReSharper restore UnusedMember.Global
// ReSharper restore InconsistentNaming
}
+54 -83
View File
@@ -59,26 +59,20 @@ namespace VocaluxeLib.Menu.SingNotes
public abstract class CSingNotes : IMenuElement
{
protected int _PartyModeID;
protected readonly int _PartyModeID;
private SThemeSingBar _Theme;
private bool _ThemeLoaded;
private readonly List<SPlayerNotes> _PlayerNotes;
private int _ActID;
private SRectF[,] _BarPos;
/// <summary>
/// Player bar positions
/// </summary>
/// <remarks>
/// first index = player number; second index = num players seen on screen
/// </remarks>
public SRectF[,] BarPos
{
get { return _BarPos; }
set { _BarPos = value; }
}
public SRectF[,] BarPos { get; set; }
public CSingNotes(int partyModeID)
{
@@ -112,20 +106,20 @@ namespace VocaluxeLib.Menu.SingNotes
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinToneHelper", out _Theme.SkinToneHelperName, String.Empty);
_ThemeLoaded &= xmlReader.GetValue(item + "/SkinPerfectNoteStar", out _Theme.SkinPerfectNoteStarName, String.Empty);
_BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
BarPos = new SRectF[CBase.Settings.GetMaxNumPlayer(),CBase.Settings.GetMaxNumPlayer()];
for (int numplayer = 0; numplayer < CBase.Settings.GetMaxNumPlayer(); numplayer++)
{
for (int player = 0; player < CBase.Settings.GetMaxNumPlayer(); player++)
{
if (player <= numplayer)
{
_BarPos[player, numplayer] = new SRectF();
BarPos[player, numplayer] = new SRectF();
string target = "/BarPositions/P" + (player + 1) + "N" + (numplayer + 1);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "X", ref _BarPos[player, numplayer].X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Y", ref _BarPos[player, numplayer].Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Z", ref _BarPos[player, numplayer].Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "W", ref _BarPos[player, numplayer].W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "H", ref _BarPos[player, numplayer].H);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "X", ref BarPos[player, numplayer].X);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Y", ref BarPos[player, numplayer].Y);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "Z", ref BarPos[player, numplayer].Z);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "W", ref BarPos[player, numplayer].W);
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + target + "H", ref BarPos[player, numplayer].H);
}
}
}
@@ -180,16 +174,15 @@ namespace VocaluxeLib.Menu.SingNotes
{
for (int player = 0; player < CBase.Settings.GetMaxNumPlayer(); player++)
{
if (player <= numplayer)
{
string target = "P" + (player + 1) + "N" + (numplayer + 1);
if (player > numplayer)
continue;
string target = "P" + (player + 1) + "N" + (numplayer + 1);
writer.WriteElementString(target + "X", _BarPos[player, numplayer].X.ToString("#0"));
writer.WriteElementString(target + "Y", _BarPos[player, numplayer].Y.ToString("#0"));
writer.WriteElementString(target + "Z", _BarPos[player, numplayer].Z.ToString("#0.00"));
writer.WriteElementString(target + "W", _BarPos[player, numplayer].W.ToString("#0"));
writer.WriteElementString(target + "H", _BarPos[player, numplayer].H.ToString("#0"));
}
writer.WriteElementString(target + "X", BarPos[player, numplayer].X.ToString("#0"));
writer.WriteElementString(target + "Y", BarPos[player, numplayer].Y.ToString("#0"));
writer.WriteElementString(target + "Z", BarPos[player, numplayer].Z.ToString("#0.00"));
writer.WriteElementString(target + "W", BarPos[player, numplayer].W.ToString("#0"));
writer.WriteElementString(target + "H", BarPos[player, numplayer].H.ToString("#0"));
}
}
writer.WriteEndElement(); //BarPositions
@@ -210,33 +203,35 @@ namespace VocaluxeLib.Menu.SingNotes
public virtual int AddPlayer(SRectF rect, SColorF color, int playerNr)
{
SPlayerNotes notes = new SPlayerNotes();
SPlayerNotes notes = new SPlayerNotes
{
Rect = rect,
Color = color,
Alpha = 1f,
ID = ++_ActID,
Lines = null,
LineNr = -1,
PlayerNr = playerNr,
Timer = new Stopwatch(),
GoldenStars = new List<CParticleEffect>(),
Flares = new List<CParticleEffect>(),
PerfectNoteEffect = new List<CParticleEffect>(),
PerfectLineTwinkle = new List<CParticleEffect>()
};
notes.Rect = rect;
notes.Color = color;
notes.Alpha = 1f;
notes.ID = ++_ActID;
notes.Lines = null;
notes.LineNr = -1;
notes.PlayerNr = playerNr;
notes.Timer = new Stopwatch();
notes.GoldenStars = new List<CParticleEffect>();
notes.Flares = new List<CParticleEffect>();
notes.PerfectNoteEffect = new List<CParticleEffect>();
notes.PerfectLineTwinkle = new List<CParticleEffect>();
_PlayerNotes.Add(notes);
return notes.ID;
}
public virtual void RemovePlayer(int iD) {}
public virtual void RemovePlayer(int id) {}
public virtual void AddLine(int iD, CLine[] line, int lineNr, int player)
public virtual void AddLine(int id, CLine[] line, int lineNr, int player)
{
if (line == null)
return;
int n = _FindPlayerLine(iD);
int n = _FindPlayerLine(id);
if (n == -1)
return;
@@ -258,13 +253,13 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes.Add(notes);
}
public virtual void RemoveLine(int iD) {}
public virtual void RemoveLine(int id) {}
public virtual void AddNote(int iD, CNote note) {}
public virtual void AddNote(int id, CNote note) {}
public virtual void SetAlpha(int iD, float alpha)
public virtual void SetAlpha(int id, float alpha)
{
int n = _FindPlayerLine(iD);
int n = _FindPlayerLine(id);
if (n == -1)
return;
@@ -273,23 +268,23 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes[n] = pn;
}
public virtual float GetAlpha(int iD)
public virtual float GetAlpha(int id)
{
int n = _FindPlayerLine(iD);
int n = _FindPlayerLine(id);
if (n == -1)
return 0f;
return _PlayerNotes[n].Alpha;
}
public virtual void Draw(int iD, int player)
public virtual void Draw(int id, int player)
{
Draw(iD, null, player);
Draw(id, null, player);
}
public virtual void Draw(int iD, List<CLine> singLine, int player)
public virtual void Draw(int id, List<CLine> singLine, int player)
{
int n = _FindPlayerLine(iD);
int n = _FindPlayerLine(id);
if (n == -1)
return;
@@ -467,30 +462,21 @@ namespace VocaluxeLib.Menu.SingNotes
LoadTextures();
}
private int _FindPlayerLine(int iD)
private int _FindPlayerLine(int id)
{
if (iD < 0 || iD > _PlayerNotes.Count)
if (id < 0 || id > _PlayerNotes.Count)
return -1;
int n = -1;
for (int i = 0; i < _PlayerNotes.Count; i++)
{
if (_PlayerNotes[i].ID == iD)
{
n = i;
break;
}
if (_PlayerNotes[i].ID == id)
return i;
}
return n;
return -1;
}
private void _DrawNote(SRectF rect, SColorF color)
{
_DrawNote(rect, color, 1f);
}
private void _DrawNote(SRectF rect, SColorF color, float factor)
private void _DrawNote(SRectF rect, SColorF color, float factor = 1f)
{
const int spacing = 0;
@@ -584,12 +570,7 @@ namespace VocaluxeLib.Menu.SingNotes
}
}
private void _AddGoldenNote(SRectF rect, int n, int nr)
{
_AddGoldenNote(rect, n, nr, 1f);
}
private void _AddGoldenNote(SRectF rect, int n, int nr, float factor)
private void _AddGoldenNote(SRectF rect, int n, int nr, float factor = 1f)
{
const int spacing = 0;
@@ -615,12 +596,7 @@ namespace VocaluxeLib.Menu.SingNotes
}
}
private void _AddFlare(SRectF rect, int n)
{
_AddFlare(rect, n, 1f);
}
private void _AddFlare(SRectF rect, int n, float factor)
private void _AddFlare(SRectF rect, int n, float factor = 1f)
{
const int spacing = 0;
@@ -642,12 +618,7 @@ namespace VocaluxeLib.Menu.SingNotes
_PlayerNotes[n].Flares.Add(flares);
}
private void _AddPerfectNote(SRectF rect, int n)
{
_AddPerfectNote(rect, n, 1f);
}
private void _AddPerfectNote(SRectF rect, int n, float factor)
private void _AddPerfectNote(SRectF rect, int n, float factor = 1f)
{
const int spacing = 0;
-5
View File
@@ -1027,10 +1027,5 @@ namespace VocaluxeLib.Menu.SongMenu
ShortEnd = stop;
}
public object Clone()
{
return MemberwiseClone();
}
}
}