diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index c968dadf..5f81b346 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -211,7 +211,7 @@ namespace Vocaluxe.Base if (_AllFileNames.Count > 0 && _CurrentMusicStream != -1) { float timeToPlay; - if (_CurrentPlaylistElement.Finish == 0f) //No End-Tag defined + if (Math.Abs(_CurrentPlaylistElement.Finish) < 0.001) //No End-Tag defined timeToPlay = CSound.GetLength(_CurrentMusicStream) - CSound.GetPosition(_CurrentMusicStream); else //End-Tag found timeToPlay = _CurrentPlaylistElement.Finish - CSound.GetPosition(_CurrentMusicStream); @@ -222,13 +222,13 @@ namespace Vocaluxe.Base if (_RepeatSong) { //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start != 0f && 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 != 0f && 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 +269,7 @@ namespace Vocaluxe.Base CSound.SetStreamVolumeMax(_CurrentMusicStream, CConfig.BackgroundMusicVolume); //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start != 0f && 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 +289,13 @@ namespace Vocaluxe.Base if (CSound.GetPosition(_CurrentMusicStream) >= 1.5f) { //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start != 0f && 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 != 0f && 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,13 +321,13 @@ namespace Vocaluxe.Base else if (_CurrentMusicStream != -1) { //Seek to #Start-Tag, if found - if (_CurrentPlaylistElement.Start != 0f && 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 != 0f && 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); @@ -434,7 +434,7 @@ namespace Vocaluxe.Base Pause(); } - if (CConfig.BackgroundMusicVolume != newVolume) + if (Math.Abs(CConfig.BackgroundMusicVolume - newVolume) > 0.01) { CConfig.BackgroundMusicVolume = (int)newVolume; ApplyVolume(); @@ -499,7 +499,7 @@ namespace Vocaluxe.Base if (_Video == -1) { _Video = CVideo.VdLoad(_CurrentPlaylistElement.VideoFilePath); - if (_CurrentPlaylistElement.Start != 0f && 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); diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 88f603cf..b3d62cdb 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -122,7 +122,7 @@ namespace Vocaluxe.Base if (Math.Abs(_Cursor.Rect.X - x) > CSettings.MouseMoveDiffMin || Math.Abs(_Cursor.Rect.Y - y) > CSettings.MouseMoveDiffMin) { - if (_CursorTargetAlpha == 0f) + if (_CursorTargetAlpha < 0.01) _Fade(1f, 0.2f); _Movetimer.Reset(); diff --git a/Vocaluxe/Base/CLog.cs b/Vocaluxe/Base/CLog.cs index 9243d516..7e9bc0c8 100644 --- a/Vocaluxe/Base/CLog.cs +++ b/Vocaluxe/Base/CLog.cs @@ -156,7 +156,7 @@ namespace Vocaluxe.Base space += " "; float ms; - if (Stopwatch.IsHighResolution && _NanosecPerTick != 0.0) + if (Stopwatch.IsHighResolution && _NanosecPerTick > 0) ms = (float)((_NanosecPerTick * _BenchmarkTimer[benchmarkNr].ElapsedTicks) / (1000.0 * 1000.0)); else ms = _BenchmarkTimer[benchmarkNr].ElapsedMilliseconds; diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index bd2756c4..9f0c1006 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -319,7 +319,7 @@ namespace Vocaluxe.Lib.Draw public void CopyScreen(ref STexture texture) { - if ((texture.Index == 0) || (texture.Width != GetScreenWidth()) || (texture.Height != GetScreenHeight())) + if (texture.Index == 0 || (int)texture.Width != GetScreenWidth() || (int)texture.Height != GetScreenHeight()) { RemoveTexture(ref texture); texture = CopyScreen(); diff --git a/Vocaluxe/Lib/Input/IInput.cs b/Vocaluxe/Lib/Input/IInput.cs index aef32f7e..a78a5018 100644 --- a/Vocaluxe/Lib/Input/IInput.cs +++ b/Vocaluxe/Lib/Input/IInput.cs @@ -57,7 +57,7 @@ namespace Vocaluxe.Lib.Input { get { - if (!_Timer.IsRunning && _Duration != 0f) + if (!_Timer.IsRunning && Math.Abs(_Duration) > float.Epsilon) { _Timer.Start(); return true; diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index 1df67e38..62b9dbdf 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -317,7 +317,7 @@ namespace Vocaluxe.Screens { _CurrentTime = CSound.GetPosition(_CurrentStream); - if (_FinishTime != 0 && _CurrentTime >= _FinishTime) + if (_FinishTime >0.001 && _CurrentTime >= _FinishTime) finish = true; } else @@ -1237,7 +1237,7 @@ namespace Vocaluxe.Screens return; float totalTime = CSound.GetLength(_CurrentStream); - if (song.Finish != 0) + if (Math.Abs(song.Finish) > 0.001) totalTime = song.Finish; float remainingTime = totalTime - _CurrentTime; @@ -1316,7 +1316,7 @@ namespace Vocaluxe.Screens return; float totalTime = CSound.GetLength(_CurrentStream); - if (song.Finish != 0) + if (Math.Abs(song.Finish) > 0.001) totalTime = song.Finish; totalTime -= song.Start; diff --git a/VocaluxeLib/Menu/CParticle.cs b/VocaluxeLib/Menu/CParticle.cs index 8aecbd89..d33001f0 100644 --- a/VocaluxeLib/Menu/CParticle.cs +++ b/VocaluxeLib/Menu/CParticle.cs @@ -105,7 +105,7 @@ namespace VocaluxeLib.Menu public bool IsAlive { - get { return _Age < _MaxAge || _MaxAge == 0f; } + get { return _Age < _MaxAge || Math.Abs(_MaxAge) < float.Epsilon; } } #endregion public vars @@ -218,7 +218,7 @@ namespace VocaluxeLib.Menu if (Math.Round(Y) < maxy) { float vdx = 0f; - if (_Vx != 0) + if (Math.Abs(_Vx) > float.Epsilon) vdx = (float)Math.Sin(currentTime / _Vx * Math.PI); X += _Vx * timediff * (0.5f + vdx); @@ -242,7 +242,7 @@ namespace VocaluxeLib.Menu // update size - if (_Vsize != 0f) + if (Math.Abs(_Vsize) > float.Epsilon) { float size = _Size; switch (_Type) @@ -275,7 +275,7 @@ namespace VocaluxeLib.Menu } // update rotation - if (_Vr != 0f) + if (Math.Abs(_Vr) > 0.01) { float r = currentTime * _Vr / 60f; _Angle = _Rotation + 360f * (r - (float)Math.Floor(r)); diff --git a/VocaluxeLib/Menu/CSelectSlide.cs b/VocaluxeLib/Menu/CSelectSlide.cs index 16fab82a..4886658a 100644 --- a/VocaluxeLib/Menu/CSelectSlide.cs +++ b/VocaluxeLib/Menu/CSelectSlide.cs @@ -503,11 +503,11 @@ namespace VocaluxeLib.Menu writer.WriteElementString("TextH", TextH.ToString("#0.00")); writer.WriteComment(": Text relative x-position"); - if (TextRelativeX != 0) + if (Math.Abs(TextRelativeX) > 0.01) writer.WriteElementString("TextRelativeX", TextRelativeX.ToString("#0.00")); writer.WriteComment(": Text relative y-position"); - if (TextRelativeY != 0) + if (Math.Abs(TextRelativeY) > 0.01) writer.WriteElementString("TextRelativeY", TextRelativeY.ToString("#0.00")); writer.WriteComment(": Maximum text width (if exists)"); diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index b09737b9..c193ed8d 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -74,7 +74,7 @@ namespace VocaluxeLib.Menu get { return _X; } set { - if (_X != value) + if (Math.Abs(_X - value) > 0.01) { _X = value; _PositionNeedsUpdate = true; @@ -89,7 +89,7 @@ namespace VocaluxeLib.Menu get { return _Y; } set { - if (_Y != value) + if (Math.Abs(_Y - value) > 0.01) { _Y = value; _PositionNeedsUpdate = true; @@ -110,7 +110,7 @@ namespace VocaluxeLib.Menu get { return _Height; } set { - if (_Height != value) + if (Math.Abs(_Height - value) > 0.01) { _Height = value; _PositionNeedsUpdate = true; @@ -124,7 +124,7 @@ namespace VocaluxeLib.Menu get { return _MaxWidth; } set { - if (_MaxWidth != value) + if (Math.Abs(_MaxWidth - value) > 0.01) { _MaxWidth = value; if (_MaxWidth > 0) @@ -143,7 +143,7 @@ namespace VocaluxeLib.Menu get { return _Bounds; } set { - if (_Bounds.X != value.X || _Bounds.Y != value.Y || _Bounds.W != value.W || _Bounds.H != value.H || _Bounds.Z != value.Z) + 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; diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs index 3243261d..474ac07a 100644 --- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs @@ -316,7 +316,7 @@ namespace VocaluxeLib.Menu.SingNotes float beats = line.LastNoteBeat - line.FirstNoteBeat + 1; - if (beats == 0) + if (beats < 1) return; SColorF color = new SColorF( diff --git a/VocaluxeLib/Menu/SongMenu/CSong.cs b/VocaluxeLib/Menu/SongMenu/CSong.cs index 06babb1b..c77e46da 100644 --- a/VocaluxeLib/Menu/SongMenu/CSong.cs +++ b/VocaluxeLib/Menu/SongMenu/CSong.cs @@ -988,7 +988,7 @@ namespace VocaluxeLib.Menu.SongMenu } } - if (PreviewStart == 0f) + if (Math.Abs(PreviewStart) < 0.001) { if (Medley.Source == EMedleySource.Calculated) PreviewStart = CBase.Game.GetTimeFromBeats(Medley.StartBeat, BPM); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs index ef2d530c..59a22604 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuFramework.cs @@ -616,7 +616,7 @@ namespace VocaluxeLib.Menu.SongMenu float startposition = CBase.Songs.GetVisibleSong(_Actsong).PreviewStart; - if (startposition == 0f) + if (Math.Abs(startposition) < 0.001) startposition = CBase.Sound.GetLength(stream) / 4f; CBase.Sound.SetPosition(stream, startposition); diff --git a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs index 2f3ee5fd..56ee0519 100644 --- a/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/VocaluxeLib/Menu/SongMenu/CSongMenuTileBoard.cs @@ -423,7 +423,7 @@ namespace VocaluxeLib.Menu.SongMenu _MedleyTagIcon.Visible = song.Medley.Source == EMedleySource.Tag; float time = CBase.Sound.GetLength(_SongStream); - if (song.Finish != 0) + if (Math.Abs(song.Finish) > 0.001) time = song.Finish; time -= song.Start;