Removed code redundancies

This commit is contained in:
Flamefire committed 2013-04-23 16:55:57 +02:00
1 parent 5cd47f0537
commit ec766aa7b5
25 files changed
+145 -243

No files matched your search

@@ -711,14 +711,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (_Fields[_Possibilities[i, j]].Content.Winner > 0)
check.Add(_Fields[_Possibilities[i, j]].Content.Winner);
}
if (check.Count == _Possibilities.GetLength(1))
{
//Check for winner
if (check.Contains(1) && !check.Contains(2))
return 1;
else if (check.Contains(2) && !check.Contains(1))
return 2;
}
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;
}
@@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using VocaluxeLib.Menu;
@@ -209,8 +210,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
return true;
}
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
else if (_SelectingMouseActive)
// LeftButton isn't hold anymore, but Selec-Mode is still active -> "Drop" of Avatar
if (_SelectingMouseActive)
{
//Check if really a player was selected
if (_SelectedPlayerNr != -1)
@@ -571,44 +572,41 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private bool _OnAdd()
{
for (int i = 0; i < _PlayerChooseButtons.Count; i++)
foreach (CPlayerChooseButton chooseButton in _PlayerChooseButtons.Where(chooseButton => chooseButton.Button.Selected && chooseButton.ProfileID != -1))
{
if (_PlayerChooseButtons[i].Button.Selected && _PlayerChooseButtons[i].ProfileID != -1)
if (_Data.ScreenNames.ProfileIDsTeam1.Count < _NumPlayerTeam1)
{
if (_Data.ScreenNames.ProfileIDsTeam1.Count < _NumPlayerTeam1)
{
_Data.ScreenNames.ProfileIDsTeam1.Add(_PlayerChooseButtons[i].ProfileID);
int added = _Data.ScreenNames.ProfileIDsTeam1.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].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
_CheckInteraction();
return true;
}
else if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2)
{
_Data.ScreenNames.ProfileIDsTeam2.Add(_PlayerChooseButtons[i].ProfileID);
int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH;
_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].Enabled = true;
//Update Tiles-List
_UpdateButtonPlayerChoose();
_CheckInteraction();
return true;
}
_Data.ScreenNames.ProfileIDsTeam1.Add(chooseButton.ProfileID);
int added = _Data.ScreenNames.ProfileIDsTeam1.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()[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();
_CheckInteraction();
return true;
}
if (_Data.ScreenNames.ProfileIDsTeam2.Count < _NumPlayerTeam2)
{
_Data.ScreenNames.ProfileIDsTeam2.Add(chooseButton.ProfileID);
int added = (_Data.ScreenNames.ProfileIDsTeam2.Count - 1) + _PlayerDestinationButtonsNumH;
_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()[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();
_CheckInteraction();
return true;
}
}
return false;
+16 -21
View File
@@ -45,7 +45,6 @@ namespace Vocaluxe.Base
private static bool _OwnMusicAdded;
private static bool _BackgroundMusicAdded;
private static bool _Playing;
private static bool _Disabled;
private static bool _CanSing;
private static bool _RepeatSong;
@@ -107,10 +106,7 @@ namespace Vocaluxe.Base
get { return File.Exists(_CurrentPlaylistElement.VideoFilePath); }
}
public static bool Playing
{
get { return _Playing; }
}
public static bool Playing { get; private set; }
public static string ArtistAndTitle
{
@@ -118,8 +114,7 @@ namespace Vocaluxe.Base
{
if (_CurrentPlaylistElement.Artist != "" && _CurrentPlaylistElement.Title != "")
return _CurrentPlaylistElement.Artist + " - " + _CurrentPlaylistElement.Title;
else
return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath);
return Path.GetFileNameWithoutExtension(_CurrentPlaylistElement.MusicFilePath);
}
}
@@ -143,12 +138,12 @@ namespace Vocaluxe.Base
if (CConfig.VideoBackgrounds == EOffOn.TR_CONFIG_ON)
_VideoEnabled = true;
_Playing = false;
Playing = false;
}
public static void Play()
{
if (_Playing)
if (Playing)
return;
if (CConfig.BackgroundMusic == EOffOn.TR_CONFIG_ON)
@@ -161,7 +156,7 @@ namespace Vocaluxe.Base
CSound.Play(_CurrentMusicStream);
if (_VideoEnabled && _Video != -1)
CVideo.VdResume(_Video);
_Playing = true;
Playing = true;
}
else
Next();
@@ -176,7 +171,7 @@ namespace Vocaluxe.Base
public static void Stop()
{
if (!_Playing)
if (!Playing)
return;
if (_VideoEnabled && _Video != -1)
@@ -189,12 +184,12 @@ namespace Vocaluxe.Base
_CurrentMusicStream = -1;
_CurrentPlaylistElement = new CPlaylistElement();
_Playing = false;
Playing = false;
}
public static void Pause()
{
if (!_Playing)
if (!Playing)
return;
if (_VideoEnabled && _Video != -1)
@@ -203,7 +198,7 @@ namespace Vocaluxe.Base
CVideo.VdSkip(_Video, CSound.GetPosition(_CurrentMusicStream) + CSettings.BackgroundMusicFadeTime, _CurrentPlaylistElement.VideoGap);
}
CSound.FadeAndPause(_CurrentMusicStream, 0f, CSettings.BackgroundMusicFadeTime);
_Playing = false;
Playing = false;
}
public static void Update()
@@ -217,7 +212,7 @@ namespace Vocaluxe.Base
timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream);
bool finished = CSound.IsFinished(_CurrentMusicStream);
if (_Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished))
if (Playing && (timeToPlay <= CSettings.BackgroundMusicFadeTime || finished))
{
if (_RepeatSong)
{
@@ -228,7 +223,7 @@ namespace Vocaluxe.Base
CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1)
{
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -269,7 +264,7 @@ namespace Vocaluxe.Base
CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume);
//Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
if (_VideoEnabled)
@@ -289,13 +284,13 @@ namespace Vocaluxe.Base
if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f)
{
//Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
else
CSound.SetPosition(_CurrentMusicStream, 0);
if (_VideoEnabled && _Video != -1)
{
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
@@ -321,7 +316,7 @@ namespace Vocaluxe.Base
else if (_CurrentMusicStream != -1)
{
//Seek to #Start-Tag, if found
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CSound.SetPosition(_CurrentMusicStream, _CurrentPlaylistElement.Start);
else
CSound.SetPosition(_CurrentMusicStream, 0);
@@ -499,7 +494,7 @@ namespace Vocaluxe.Base
if (_Video == -1)
{
_Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath);
if (_CurrentPlaylistElement.Start >0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
if (_CurrentPlaylistElement.Start > 0.001 && CConfig.BackgroundMusicUseStart == EOffOn.TR_CONFIG_ON)
CVideo.VdSkip(_Video, _CurrentPlaylistElement.Start, _CurrentPlaylistElement.VideoGap);
else
CVideo.VdSkip(_Video, 0f, _CurrentPlaylistElement.VideoGap);
+21 -24
View File
@@ -314,31 +314,28 @@ namespace Vocaluxe.Base
reader.Dispose();
return id;
}
else
if (reader != null)
reader.Close();
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
"VALUES (@title, @artist, @numplayed)";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed;
command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
reader = command.ExecuteReader();
if (reader != null)
{
if (reader != null)
reader.Close();
command.CommandText = "INSERT INTO Songs (Title, Artist, NumPlayed) " +
"VALUES (@title, @artist, @numplayed)";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
command.Parameters.Add("@numplayed", DbType.Int32, 0).Value = defNumPlayed;
command.ExecuteNonQuery();
command.CommandText = "SELECT id FROM Songs WHERE [Title] = @title AND [Artist] = @artist";
command.Parameters.Add("@title", DbType.String, 0).Value = title;
command.Parameters.Add("@artist", DbType.String, 0).Value = artist;
reader = command.ExecuteReader();
if (reader != null)
{
reader.Read();
int id = reader.GetInt32(0);
reader.Dispose();
return id;
}
reader.Read();
int id = reader.GetInt32(0);
reader.Dispose();
return id;
}
return -1;
+2 -5
View File
@@ -225,11 +225,8 @@ namespace Vocaluxe.Base
_Languages[nr].PartyModeTexts.Add(lang);
return true;
}
else
{
CLog.LogError("Error reading Party Language File " + file);
return false;
}
CLog.LogError("Error reading Party Language File " + file);
return false;
}
private static void _LoadLanguageFile(string fileName)
+2
View File
@@ -160,7 +160,9 @@ namespace Vocaluxe.Base
{
string version = ProgramName;
// ReSharper disable ConditionIsAlwaysTrueOrFalse
if (ProgramCodeName != "")
// ReSharper restore ConditionIsAlwaysTrueOrFalse
version += " \"" + ProgramCodeName + "\"";
return version + " " + GetVersionText();
+19 -35
View File
@@ -50,11 +50,10 @@ namespace Vocaluxe.Base
get { return _IgnoreArticles; }
set
{
if (value != _IgnoreArticles)
{
_IgnoreArticles = value;
_SetChanged();
}
if (value == _IgnoreArticles)
return;
_IgnoreArticles = value;
_SetChanged();
}
}
@@ -63,11 +62,10 @@ namespace Vocaluxe.Base
get { return _SongSorting; }
set
{
if (value != _SongSorting)
{
_SongSorting = value;
_SetChanged();
}
if (value == _SongSorting)
return;
_SongSorting = value;
_SetChanged();
}
}
@@ -88,36 +86,28 @@ namespace Vocaluxe.Base
private int _SortByFieldArtistTitle(SSongPointer s1, SSongPointer s2)
{
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase);
if (res == 0)
{
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
{
res = CSongs.Songs[s1.SongID].ArtistSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].ArtistSorting.ToUpper());
if (res == 0)
return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper());
return res;
}
else
{
res = CSongs.Songs[s1.SongID].Artist.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Artist.ToUpper());
if (res == 0)
return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper());
return res;
res = String.Compare(CSongs.Songs[s1.SongID].ArtistSorting, CSongs.Songs[s2.SongID].ArtistSorting, StringComparison.OrdinalIgnoreCase);
return res != 0 ? res: String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase);
}
res = String.Compare(CSongs.Songs[s1.SongID].Artist, CSongs.Songs[s2.SongID].Artist, StringComparison.OrdinalIgnoreCase);
return res != 0 ? res : String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase);
}
return res;
}
private int _SortByFieldTitle(SSongPointer s1, SSongPointer s2)
{
int res = s1.SortString.ToUpper().CompareTo(s2.SortString.ToUpper());
int res = String.Compare(s1.SortString, s2.SortString, StringComparison.OrdinalIgnoreCase);
if (res == 0)
{
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
return CSongs.Songs[s1.SongID].TitleSorting.ToUpper().CompareTo(CSongs.Songs[s2.SongID].TitleSorting.ToUpper());
else
return CSongs.Songs[s1.SongID].Title.ToUpper().CompareTo(CSongs.Songs[s2.SongID].Title.ToUpper());
return _IgnoreArticles == EOffOn.TR_CONFIG_ON
? String.Compare(CSongs.Songs[s1.SongID].TitleSorting, CSongs.Songs[s2.SongID].TitleSorting, StringComparison.OrdinalIgnoreCase) :
String.Compare(CSongs.Songs[s1.SongID].Title, CSongs.Songs[s2.SongID].Title, StringComparison.OrdinalIgnoreCase);
}
return res;
}
@@ -177,16 +167,10 @@ namespace Vocaluxe.Base
break;
case ESongSorting.TR_CONFIG_ARTIST_LETTER:
case ESongSorting.TR_CONFIG_ARTIST:
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
fieldName = "ArtistSorting";
else
fieldName = "Artist";
fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "ArtistSorting" : "Artist";
break;
case ESongSorting.TR_CONFIG_TITLE_LETTER:
if (_IgnoreArticles == EOffOn.TR_CONFIG_ON)
fieldName = "TitleSorting";
else
fieldName = "Title";
fieldName = _IgnoreArticles == EOffOn.TR_CONFIG_ON ? "TitleSorting" : "Title";
break;
case ESongSorting.TR_CONFIG_YEAR:
case ESongSorting.TR_CONFIG_DECADE:
+1 -2
View File
@@ -205,8 +205,7 @@ namespace Vocaluxe.Base
{
if ((Categorizer.Categories.Count > 0) && (_CatIndex >= 0) && (Categorizer.Categories.Count > _CatIndex))
return Categorizer.Categories[_CatIndex].Name;
else
return String.Empty;
return String.Empty;
}
public static CSong GetSong(int songID)
+6 -26
View File
@@ -548,7 +548,7 @@ namespace Vocaluxe.Base
{
if (partyModeID != -1 && _Skins[i].PartyModeID == partyModeID)
return i;
else if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin)
if (partyModeID == -1 && _Skins[i].Name == CConfig.Skin)
return i;
}
@@ -561,7 +561,7 @@ namespace Vocaluxe.Base
{
if (partyModeID != -1 && _Themes[i].PartyModeID == partyModeID)
return i;
else if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme)
if (partyModeID == -1 && _Themes[i].Name == CConfig.Theme)
return i;
}
@@ -597,22 +597,12 @@ namespace Vocaluxe.Base
return _GetSkinFileName(skinName, GetSkinIndex(partyModeID), true);
}
private static string _GetSkinFileName(string skinName, int skinIndex)
{
return _GetSkinFileName(skinName, skinIndex, false);
}
private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath)
private static string _GetSkinFileName(string skinName, int skinIndex, bool returnPath = false)
{
foreach (SSkinElement sk in _Skins[skinIndex].SkinList.Values)
{
if (sk.Name == skinName)
{
if (!returnPath)
return sk.Value;
else
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
CLog.LogError("Can't find Skin Element \"" + skinName);
@@ -695,22 +685,12 @@ namespace Vocaluxe.Base
return _GetVideoFileName(videoName, GetSkinIndex(partyModeID), true);
}
private static string _GetVideoFileName(string videoName, int skinIndex)
{
return _GetVideoFileName(videoName, skinIndex, false);
}
private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath)
private static string _GetVideoFileName(string videoName, int skinIndex, bool returnPath = false)
{
foreach (SSkinElement sk in _Skins[skinIndex].VideoList)
{
if (sk.Name == videoName)
{
if (!returnPath)
return sk.Value;
else
return Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
return !returnPath ? sk.Value : Path.Combine(_Skins[skinIndex].Path, sk.Value);
}
CLog.LogError("Can't find Video Element \"" + videoName);
+3 -6
View File
@@ -59,11 +59,9 @@ namespace Vocaluxe.Base
long ticks = _Stopwatch.ElapsedTicks;
if (Stopwatch.IsHighResolution && ticks != 0)
return (float)((_NanosecPerTick * ticks) / (1000.0 * 1000.0));
else
return _Stopwatch.ElapsedMilliseconds;
return _Stopwatch.ElapsedMilliseconds;
}
else
return 0f;
return 0f;
}
public static float CalculateFPS()
@@ -190,8 +188,7 @@ namespace Vocaluxe.Base
_Del(0);
return true;
}
else
return false;
return false;
}
public void CopyEvents()
-2
View File
@@ -17,8 +17,6 @@
// */
#endregion
using System;
namespace Vocaluxe.Lib.Sound
{
struct SAudioStreams
+1 -1
View File
@@ -661,7 +661,7 @@ namespace Vocaluxe.Lib.Video
if (num >= 0)
{
if (frame.Index == -1 || _Width != (int) frame.Width || _Height != (int) frame.Height)
if (frame.Index == -1 || _Width != (int)frame.Width || _Height != (int)frame.Height)
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, ref _FrameBuffer[num].Data);
-1
View File
@@ -17,7 +17,6 @@
// */
#endregion
using System;
using VocaluxeLib.Menu;
namespace Vocaluxe.Lib.Video
+1 -2
View File
@@ -17,7 +17,6 @@
// */
#endregion
using System;
using AForge.Video;
using AForge.Video.DirectShow;
using System.Collections.Generic;
@@ -57,7 +56,7 @@ namespace Vocaluxe.Lib.Webcam
{
lock (_MutexData)
{
if (frame.Index == -1 || _Width != (int) frame.Width || _Height != (int)frame.Height)
if (frame.Index == -1 || _Width != (int)frame.Width || _Height != (int)frame.Height)
{
CDraw.RemoveTexture(ref frame);
frame = CDraw.AddTexture(_Width, _Height, ref _Data);
+4 -6
View File
@@ -317,7 +317,7 @@ namespace Vocaluxe.Screens
{
_CurrentTime = CSound.GetPosition(_CurrentStream);
if (_FinishTime >0.001 && _CurrentTime >= _FinishTime)
if (_FinishTime > 0.001 && _CurrentTime >= _FinishTime)
finish = true;
}
else
@@ -1038,13 +1038,11 @@ namespace Vocaluxe.Screens
private float[] _CalcFadingAlpha()
{
float dt = 4f;
float rt = dt * 0.8f;
const float dt = 4f;
const float rt = dt * 0.8f;
CSong song = CGame.GetSong();
if (song == null)
return null;
else if (!song.NotesLoaded)
if (song == null || !song.NotesLoaded)
return null;
float[] alpha = new float[song.Notes.Lines.Length * 2];
+6 -9
View File
@@ -463,24 +463,24 @@ namespace Vocaluxe.Screens
_ToggleSongOptions(ESongOptionsView.General);
return true;
}
else if (_Buttons[_ButtonOptionsClose].Selected)
if (_Buttons[_ButtonOptionsClose].Selected)
{
_ToggleSongOptions(ESongOptionsView.None);
return true;
}
else if (_Buttons[_ButtonOptionsSing].Selected)
if (_Buttons[_ButtonOptionsSing].Selected)
{
_ToggleSongOptions(ESongOptionsView.None);
_StartSong(_SongMenus[_SongMenu].GetSelectedSong());
return true;
}
else if (_Buttons[_ButtonOptionsPlaylist].Selected)
if (_Buttons[_ButtonOptionsPlaylist].Selected)
{
_ToggleSongOptions(ESongOptionsView.None);
_OpenAndAddPlaylistAction();
return true;
}
else if (_Buttons[_ButtonOptionsRandom].Selected)
if (_Buttons[_ButtonOptionsRandom].Selected)
{
if (CSongs.IsInCategory)
{
@@ -558,11 +558,8 @@ namespace Vocaluxe.Screens
_ToggleSongOptions(ESongOptionsView.Song);
return true;
}
else
{
_ToggleSongOptions(ESongOptionsView.None);
return true;
}
_ToggleSongOptions(ESongOptionsView.None);
return true;
}
}
+1 -1
View File
@@ -503,7 +503,7 @@ namespace VocaluxeLib.Menu
if (diff <= 0)
diff = 1;
float p = 1f-(currentBeat - _Notes[jumpNote].StartBeat) / diff;
float p = 1f - (currentBeat - _Notes[jumpNote].StartBeat) / diff;
if (Math.Abs(p) < float.Epsilon)
_Text.Draw();
+3 -12
View File
@@ -500,10 +500,7 @@ namespace VocaluxeLib.Menu
if (_Selection >= _Interactions.Count || _Selection < 0)
return false;
if (_Interactions.Count > 0)
return _IsMouseOver(x, y, _Interactions[_Selection]);
else
return false;
return _Interactions.Count > 0 && _IsMouseOver(x, y, _Interactions[_Selection]);
}
private bool _IsMouseOver(int x, int y, CInteraction interact)
@@ -789,10 +786,7 @@ namespace VocaluxeLib.Menu
inDirection = true;
break;
}
if (!inDirection)
return float.MaxValue;
else
return distance;
return !inDirection ? float.MaxValue : distance;
}
private float _GetDistance180(SKeyEvent key, SRectF actualRect, SRectF targetRect)
@@ -825,10 +819,7 @@ namespace VocaluxeLib.Menu
inDirection = true;
break;
}
if (!inDirection)
return float.MaxValue;
else
return distance;
return !inDirection ? float.MaxValue : distance;
}
/// <summary>
+6 -7
View File
@@ -873,7 +873,7 @@ namespace VocaluxeLib.Menu
}
return true;
}
else if (mouseEvent.Wheel < 0)
if (mouseEvent.Wheel < 0)
{
if (Offset + mouseEvent.Wheel >= 0)
{
@@ -925,23 +925,23 @@ namespace VocaluxeLib.Menu
ClosePlaylist();
return true;
}
else if (_Theme.ButtonPlaylistSing.Selected)
if (_Theme.ButtonPlaylistSing.Selected)
{
_StartPlaylistSongs();
return true;
}
else if (_Theme.ButtonPlaylistSave.Selected)
if (_Theme.ButtonPlaylistSave.Selected)
{
CBase.Playlist.SavePlaylist(ActivePlaylistID);
return true;
}
else if (_Theme.ButtonPlaylistDelete.Selected)
if (_Theme.ButtonPlaylistDelete.Selected)
{
CBase.Playlist.DeletePlaylist(ActivePlaylistID);
ClosePlaylist();
return true;
}
else if (_Theme.ButtonPlaylistName.Selected)
if (_Theme.ButtonPlaylistName.Selected)
{
EditMode = EEditMode.PlaylistName;
_Theme.ButtonPlaylistName.EditMode = true;
@@ -1159,8 +1159,7 @@ namespace VocaluxeLib.Menu
Update();
return true;
}
else
return false;
return false;
}
public void UpdatePlaylist()
+1 -2
View File
@@ -134,8 +134,7 @@ namespace VocaluxeLib.Menu
{
if (_Selection >= 0 && _ValueIndexes.Count > _Selection)
return _ValueIndexes[_Selection];
else
return -1;
return -1;
}
}
+1 -7
View File
@@ -45,13 +45,7 @@ namespace VocaluxeLib.Menu
private STexture _Texture;
public STexture Texture
{
get
{
if (_Texture.Index != -1)
return _Texture;
else
return CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
}
get { return _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); }
set { _Texture = value; }
}
+2 -1
View File
@@ -143,7 +143,8 @@ namespace VocaluxeLib.Menu
get { return _Bounds; }
set
{
if (Math.Abs(_Bounds.X - value.X) > 0.01 || Math.Abs(_Bounds.Y - value.Y) > 0.01 || Math.Abs(_Bounds.W - value.W) > 0.01 || Math.Abs(_Bounds.H - value.H) > 0.01 || Math.Abs(_Bounds.Z - value.Z) > 0.01)
if (Math.Abs(_Bounds.X - value.X) > 0.01 || Math.Abs(_Bounds.Y - value.Y) > 0.01 || Math.Abs(_Bounds.W - value.W) > 0.01 || Math.Abs(_Bounds.H - value.H) > 0.01 ||
Math.Abs(_Bounds.Z - value.Z) > 0.01)
{
_Bounds = value;
_PositionNeedsUpdate = true;
+2 -14
View File
@@ -379,24 +379,12 @@ namespace VocaluxeLib.Menu.SingNotes
public CNote FirstNote
{
get
{
if (_Notes.Count > 0)
return _Notes[0];
else
return null;
}
get { return _Notes.Count > 0 ? _Notes[0] : null; }
}
public CNote LastNote
{
get
{
if (_Notes.Count > 0)
return _Notes[_Notes.Count - 1];
else
return null;
}
get { return _Notes.Count > 0 ? _Notes[_Notes.Count - 1] : null; }
}
public int BaseLine
+3 -12
View File
@@ -66,13 +66,7 @@ namespace VocaluxeLib.Menu.SongMenu
public STexture CoverTextureBig
{
get
{
if (_CoverBigLoaded)
return _CoverTextureBig;
else
return _CoverTextureSmall;
}
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
set
{
if (value.Index != -1)
@@ -1016,11 +1010,8 @@ namespace VocaluxeLib.Menu.SongMenu
ShortEnd = lines.Line[series[i].Start - 1].LastNote.EndBeat;
return;
}
else
{
ShortEnd = lines.Line[series[i].End].LastNote.EndBeat;
return;
}
ShortEnd = lines.Line[series[i].End].LastNote.EndBeat;
return;
}
}
@@ -367,7 +367,7 @@ namespace VocaluxeLib.Menu.SongMenu
mouseEvent.Handled = true;
return;
}
else if (mouseEvent.RB && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode)
if (mouseEvent.RB && CBase.Songs.GetTabs() == EOffOn.TR_CONFIG_OFF && !songOptions.Selection.PartyMode)
CBase.Graphics.FadeTo(EScreens.ScreenMain);
else if (_PreviewSelected != -1 && mouseEvent.LB && CBase.Songs.GetCurrentCategoryIndex() != -1 && !songOptions.Selection.PartyMode)
{