From 0c636929a27b6c0ca65f0013e5c838ecd08926ef Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Fri, 14 Dec 2012 16:12:58 +0100 Subject: [PATCH] moved CSong to SongMenu/CSong.cs --- Vocaluxe/Base/CBackgroundMusic.cs | 5 +- Vocaluxe/Base/CDataBase.cs | 2 +- Vocaluxe/Base/CGame.cs | 2 +- Vocaluxe/Base/CMain.cs | 193 +++++++++++++++++- Vocaluxe/Base/CPlaylists.cs | 1 - Vocaluxe/Base/CSongs.cs | 5 +- Vocaluxe/Base/CUtility.cs | 35 ---- Vocaluxe/GameModes/CGameMode.cs | 1 - Vocaluxe/GameModes/IGameMode.cs | 2 +- Vocaluxe/Lib/Playlist/CPlaylistFile.cs | 2 +- Vocaluxe/Menu/CHelper.cs | 35 ++++ Vocaluxe/Menu/CMenu.cs | 13 +- Vocaluxe/Menu/CPlaylist.cs | 2 +- Vocaluxe/Menu/IMenu.cs | 65 +++++- Vocaluxe/Menu/SingNotes/CNotes.cs | 2 +- Vocaluxe/{Lib/Song => Menu/SongMenu}/CSong.cs | 79 +++---- Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs | 72 ++++--- Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs | 2 +- Vocaluxe/Screens/CPopupScreenPlayerControl.cs | 2 +- Vocaluxe/Screens/CPopupScreenVolumeControl.cs | 2 +- Vocaluxe/Screens/CScreenHighscore.cs | 2 +- Vocaluxe/Screens/CScreenLoad.cs | 2 +- Vocaluxe/Screens/CScreenScore.cs | 2 +- Vocaluxe/Screens/CScreenSing.cs | 3 +- Vocaluxe/Screens/CScreenSong.cs | 3 +- Vocaluxe/Vocaluxe.csproj | 2 +- 26 files changed, 399 insertions(+), 137 deletions(-) rename Vocaluxe/{Lib/Song => Menu/SongMenu}/CSong.cs (90%) diff --git a/Vocaluxe/Base/CBackgroundMusic.cs b/Vocaluxe/Base/CBackgroundMusic.cs index fb3ea35c..258e811f 100644 --- a/Vocaluxe/Base/CBackgroundMusic.cs +++ b/Vocaluxe/Base/CBackgroundMusic.cs @@ -1,14 +1,15 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Text; using System.IO; using Vocaluxe.Base; using System.Diagnostics; -using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Draw; -using System.Drawing; + using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CDataBase.cs b/Vocaluxe/Base/CDataBase.cs index 591dca1a..bc5bb49a 100644 --- a/Vocaluxe/Base/CDataBase.cs +++ b/Vocaluxe/Base/CDataBase.cs @@ -20,8 +20,8 @@ using SQLiteDataReader = Mono.Data.Sqlite.SqliteDataReader; using Community.CsharpSqlite; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index eb7a51e2..e825b4b7 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -6,9 +6,9 @@ using System.Text; using Vocaluxe.GameModes; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; using Vocaluxe.Menu.SingNotes; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Base { diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index e8aee56e..0c463ee4 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -4,6 +4,7 @@ using System.Drawing; using System.Text; using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Base { @@ -22,8 +23,15 @@ namespace Vocaluxe.Base public static IGame Game = new BGame(); public static IProfiles Profiles = new BProfiles(); public static IRecording Record = new BRecord(); + public static ISongs Songs = new BSongs(); + public static IVideo Video = new BVideo(); + public static ISound Sound = new BSound(); + public static ICover Cover = new BCover(); + public static IDataBase DataBase = new BDataBase(); - public static Menu.Base Base = new Menu.Base(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, Game, Profiles, Record); + + public static Menu.Base Base = new Menu.Base( + Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, Game, Profiles, Record, Songs, Video, Sound, Cover, DataBase); } class BConfig : IConfig @@ -45,6 +53,11 @@ namespace Vocaluxe.Base return CConfig.BackgroundMusicVolume; } + public int GetPreviewMusicVolume() + { + return CConfig.PreviewMusicVolume; + } + public ESongMenu GetSongMenuType() { return CConfig.SongMenu; @@ -60,6 +73,11 @@ namespace Vocaluxe.Base return CConfig.VideoBackgrounds; } + public EOffOn GetVideoPreview() + { + return CConfig.VideoPreview; + } + public EOffOn GetDrawNoteLines() { return CConfig.DrawNoteLines; @@ -69,6 +87,16 @@ namespace Vocaluxe.Base { return CConfig.DrawToneHelper; } + + public int GetCoverSize() + { + return CConfig.CoverSize; + } + + public List GetSongFolder() + { + return CConfig.SongFolder; + } } class BSettings : ISettings @@ -122,6 +150,26 @@ namespace Vocaluxe.Base { return CSettings.MaxNumPlayer; } + + public float GetDefaultMedleyFadeInTime() + { + return CSettings.DefaultMedleyFadeInTime; + } + + public float GetDefaultMedleyFadeOutTime() + { + return CSettings.DefaultMedleyFadeOutTime; + } + + public int GetMedleyMinSeriesLength() + { + return CSettings.MedleyMinSeriesLength; + } + + public float GetMedleyMinDuration() + { + return CSettings.MedleyMinDuration; + } } class BTheme : ITheme @@ -279,6 +327,11 @@ namespace Vocaluxe.Base CDraw.DrawTextureReflection(Texture, Rect, Color, Bounds, ReflectionSpace, ReflectionHeight); } + public void RemoveTexture(ref STexture Texture) + { + CDraw.RemoveTexture(ref Texture); + } + public void DrawColor(SColorF Color, SRectF Rect) { CDraw.DrawColor(Color, Rect); @@ -383,6 +436,11 @@ namespace Vocaluxe.Base { return CGame.Rand.NextDouble(); } + + public float GetTimeFromBeats(float Beat, float BPM) + { + return CGame.GetTimeFromBeats(Beat, BPM); + } } class BProfiles : IProfiles @@ -400,4 +458,137 @@ namespace Vocaluxe.Base return CSound.RecordGetToneAbs(PlayerNr); } } + + class BSongs : ISongs + { + public int GetNumVisibleSongs() + { + return CSongs.NumVisibleSongs; + } + + public int GetNumCategories() + { + return CSongs.NumCategories; + } + + public int GetCurrentCategoryIndex() + { + return CSongs.Category; + } + + public void SetCategory(int CategoryIndex) + { + CSongs.Category = CategoryIndex; + } + + public CSong GetVisibleSong(int VisibleIndex) + { + if (VisibleIndex >= CSongs.NumVisibleSongs) + return null; + + CSong song = CSongs.VisibleSongs[VisibleIndex]; + if (song == null) + return null; + + return new CSong(song); + } + } + + class BVideo : IVideo + { + public int Load(string VideoFileName) + { + return CVideo.VdLoad(VideoFileName); + } + + public bool Skip(int VideoStream, float StartPosition, float VideoGap) + { + return CVideo.VdSkip(VideoStream, StartPosition, VideoGap); + } + + public bool GetFrame(int VideoStream, ref STexture VideoTexture, float Time, ref float VideoTime) + { + return CVideo.VdGetFrame(VideoStream, ref VideoTexture, Time, ref VideoTime); + } + + public bool IsFinished(int VideoStream) + { + return CVideo.VdFinished(VideoStream); + } + + public bool Close(int VideoStream) + { + return CVideo.VdClose(VideoStream); + } + + } + + class BSound : ISound + { + public int Load(string SoundFile, bool Prescan) + { + return CSound.Load(SoundFile, Prescan); + } + + public void SetPosition(int SoundStream, float NewPosition) + { + CSound.SetPosition(SoundStream, NewPosition); + } + + public void Play(int SoundStream) + { + CSound.Play(SoundStream); + } + + public void Fade(int SoundStream, float TargetVolume, float Duration) + { + CSound.Fade(SoundStream, TargetVolume, Duration); + } + + public bool IsFinished(int SoundStream) + { + return CSound.IsFinished(SoundStream); + } + + public float GetPosition(int SoundStream) + { + return CSound.GetPosition(SoundStream); + } + + public float GetLength(int SoundStream) + { + return CSound.GetLength(SoundStream); + } + + public void FadeAndStop(int SoundStream, float TargetVolume, float Duration) + { + CSound.FadeAndStop(SoundStream, TargetVolume, Duration); + } + + public void SetStreamVolume(int SoundStream, float Volume) + { + CSound.SetStreamVolume(SoundStream, Volume); + } + + public void SetStreamVolumeMax(int SoundStream, float MaxVolume) + { + CSound.SetStreamVolumeMax(SoundStream, MaxVolume); + } + } + + class BCover : ICover + { + public STexture GetNoCover() + { + return CCover.NoCover; + } + } + + class BDataBase : IDataBase + { + public bool GetCover(string FileName, ref STexture Texture, int CoverSize) + { + return CDataBase.GetCover(FileName, ref Texture, CoverSize); + } + } } diff --git a/Vocaluxe/Base/CPlaylists.cs b/Vocaluxe/Base/CPlaylists.cs index 0c2daa0e..6ddd2edc 100644 --- a/Vocaluxe/Base/CPlaylists.cs +++ b/Vocaluxe/Base/CPlaylists.cs @@ -5,7 +5,6 @@ using System.Text; using System.Xml; using System.Xml.XPath; -using Vocaluxe.Lib.Song; using Vocaluxe.Lib.Playlist; using Vocaluxe.Menu; diff --git a/Vocaluxe/Base/CSongs.cs b/Vocaluxe/Base/CSongs.cs index 45c14e9d..0cb326a6 100644 --- a/Vocaluxe/Base/CSongs.cs +++ b/Vocaluxe/Base/CSongs.cs @@ -8,8 +8,9 @@ using System.Text.RegularExpressions; using System.Threading; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; + using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Base { @@ -958,7 +959,7 @@ namespace Vocaluxe.Base CLog.StartBenchmark(2, "Read TXTs"); foreach (string file in files) { - CSong Song = new CSong(); + CSong Song = new CSong(CMain.Base); if (Song.ReadTXTSong(file)) { Song.ID = _Songs.Count; diff --git a/Vocaluxe/Base/CUtility.cs b/Vocaluxe/Base/CUtility.cs index d3f97704..81029815 100644 --- a/Vocaluxe/Base/CUtility.cs +++ b/Vocaluxe/Base/CUtility.cs @@ -348,39 +348,4 @@ namespace Vocaluxe.Base } } - - static class CEncoding - { - public static Encoding GetEncoding(string EncodingName) - { - switch (EncodingName) - { - case "AUTO": - return Encoding.Default; - case "CP1250": - return Encoding.GetEncoding(1250); - case "CP1252": - return Encoding.GetEncoding(1252); - case "LOCALE": - return Encoding.Default; - case "UTF8": - return Encoding.UTF8; - default: - return Encoding.UTF8; - } - } - - public static string GetEncodingName(Encoding Enc) - { - string Result = "UTF8"; - - if (Enc.CodePage == 1250) - Result = "CP1250"; - - if (Enc.CodePage == 1252) - Result = "CP1252"; - - return Result; - } - } } diff --git a/Vocaluxe/GameModes/CGameMode.cs b/Vocaluxe/GameModes/CGameMode.cs index 16121b10..bac7fb6e 100644 --- a/Vocaluxe/GameModes/CGameMode.cs +++ b/Vocaluxe/GameModes/CGameMode.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.Text; using Vocaluxe.Base; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; using Vocaluxe.Menu.SongMenu; diff --git a/Vocaluxe/GameModes/IGameMode.cs b/Vocaluxe/GameModes/IGameMode.cs index 9d564c6b..ec649af5 100644 --- a/Vocaluxe/GameModes/IGameMode.cs +++ b/Vocaluxe/GameModes/IGameMode.cs @@ -3,8 +3,8 @@ using System.Collections.Generic; using System.Text; using Vocaluxe.Base; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.GameModes { diff --git a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs index c22cb99e..662a4ba4 100644 --- a/Vocaluxe/Lib/Playlist/CPlaylistFile.cs +++ b/Vocaluxe/Lib/Playlist/CPlaylistFile.cs @@ -7,8 +7,8 @@ using System.Xml.XPath; using Vocaluxe.Base; using Vocaluxe.GameModes; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Lib.Playlist diff --git a/Vocaluxe/Menu/CHelper.cs b/Vocaluxe/Menu/CHelper.cs index f8e1bb40..f051e87e 100644 --- a/Vocaluxe/Menu/CHelper.cs +++ b/Vocaluxe/Menu/CHelper.cs @@ -310,4 +310,39 @@ namespace Vocaluxe.Menu return ((bounds.X <= x) && (bounds.X + bounds.W >= x) && (bounds.Y <= y) && (bounds.Y + bounds.H >= y)); } } + + static class CEncoding + { + public static Encoding GetEncoding(string EncodingName) + { + switch (EncodingName) + { + case "AUTO": + return Encoding.Default; + case "CP1250": + return Encoding.GetEncoding(1250); + case "CP1252": + return Encoding.GetEncoding(1252); + case "LOCALE": + return Encoding.Default; + case "UTF8": + return Encoding.UTF8; + default: + return Encoding.UTF8; + } + } + + public static string GetEncodingName(Encoding Enc) + { + string Result = "UTF8"; + + if (Enc.CodePage == 1250) + Result = "CP1250"; + + if (Enc.CodePage == 1252) + Result = "CP1252"; + + return Result; + } + } } diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index 396588ac..0f6ec05f 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -2337,9 +2337,15 @@ namespace Vocaluxe.Menu public IGame Game; public IProfiles Profiles; public IRecording Record; + public ISongs Songs; + public IVideo Video; + public ISound Sound; + public ICover Cover; + public IDataBase DataBase; public Base(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, - IDrawing Draw, IGraphics Graphics, IFonts Fonts, ILanguage Language, IGame Game, IProfiles Profiles, IRecording Record) + IDrawing Draw, IGraphics Graphics, IFonts Fonts, ILanguage Language, IGame Game, IProfiles Profiles, IRecording Record, + ISongs Songs, IVideo Video, ISound Sound, ICover Cover, IDataBase DataBase) { this.Config = Config; this.Settings = Settings; @@ -2354,6 +2360,11 @@ namespace Vocaluxe.Menu this.Game = Game; this.Profiles = Profiles; this.Record = Record; + this.Songs = Songs; + this.Video = Video; + this.Sound = Sound; + this.Cover = Cover; + this.DataBase = DataBase; } } } diff --git a/Vocaluxe/Menu/CPlaylist.cs b/Vocaluxe/Menu/CPlaylist.cs index ccc3c50a..edacee0d 100644 --- a/Vocaluxe/Menu/CPlaylist.cs +++ b/Vocaluxe/Menu/CPlaylist.cs @@ -8,7 +8,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; +using Vocaluxe.Menu.SongMenu; using Vocaluxe.GameModes; namespace Vocaluxe.Menu diff --git a/Vocaluxe/Menu/IMenu.cs b/Vocaluxe/Menu/IMenu.cs index 4a3555fd..3bd80bd5 100644 --- a/Vocaluxe/Menu/IMenu.cs +++ b/Vocaluxe/Menu/IMenu.cs @@ -5,6 +5,7 @@ using System.Text; using System.Windows.Forms; using Vocaluxe.Menu.SingNotes; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Menu { @@ -47,13 +48,20 @@ namespace Vocaluxe.Menu void SetBackgroundMusicVolume(int NewVolume); int GetBackgroundMusicVolume(); + int GetPreviewMusicVolume(); + EOffOn GetVideosToBackground(); EOffOn GetVideoBackgrounds(); + EOffOn GetVideoPreview(); ESongMenu GetSongMenuType(); EOffOn GetDrawNoteLines(); EOffOn GetDrawToneHelper(); + + int GetCoverSize(); + + List GetSongFolder(); } public interface ISettings @@ -72,6 +80,11 @@ namespace Vocaluxe.Menu int GetNumNoteLines(); int GetMaxNumPlayer(); + + float GetDefaultMedleyFadeInTime(); + float GetDefaultMedleyFadeOutTime(); + int GetMedleyMinSeriesLength(); + float GetMedleyMinDuration(); } public interface ITheme @@ -124,6 +137,8 @@ namespace Vocaluxe.Menu void DrawTexture(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds); void DrawTextureReflection(STexture Texture, SRectF Rect, SColorF Color, SRectF Bounds, float ReflectionSpace, float ReflectionHeight); + void RemoveTexture(ref STexture Texture); + void DrawColor(SColorF Color, SRectF Rect); void DrawColorReflection(SColorF Color, SRectF Rect, float Space, float Height); } @@ -165,6 +180,8 @@ namespace Vocaluxe.Menu int GetRandom(int Max); double GetRandomDouble(); + + float GetTimeFromBeats(float Beat, float BPM); } public interface IRecording @@ -177,6 +194,52 @@ namespace Vocaluxe.Menu SProfile[] GetProfiles(); } + public interface ISongs + { + int GetNumVisibleSongs(); + int GetNumCategories(); + int GetCurrentCategoryIndex(); + + void SetCategory(int CategoryIndex); + + CSong GetVisibleSong(int VisibleIndex); + } + + public interface IVideo + { + int Load(string VideoFileName); + bool Skip(int VideoStream, float StartPosition, float VideoGap); + bool GetFrame(int VideoStream, ref STexture VideoTexture, float Time, ref float VideoTime); + bool IsFinished(int VideoStream); + bool Close(int VideoStream); + } + + public interface ISound + { + int Load(string SoundFile, bool Prescan); + void SetPosition(int SoundStream, float NewPosition); + void Play(int SoundStream); + void Fade(int SoundStream, float TargetVolume, float Duration); + + bool IsFinished(int SoundStream); + float GetPosition(int SoundStream); + float GetLength(int SoundStream); + void FadeAndStop(int SoundStream, float TargetVolume, float Duration); + + void SetStreamVolume(int SoundStream, float Volume); + void SetStreamVolumeMax(int SoundStream, float MaxVolume); + } + + public interface ICover + { + STexture GetNoCover(); + } + + public interface IDataBase + { + bool GetCover(string FileName, ref STexture Texture, int CoverSize); + } + [Flags] public enum EModifier { @@ -305,7 +368,7 @@ namespace Vocaluxe.Menu EditTheme } - enum EAspect + public enum EAspect { Crop, LetterBox, diff --git a/Vocaluxe/Menu/SingNotes/CNotes.cs b/Vocaluxe/Menu/SingNotes/CNotes.cs index 80685b2e..5b1f91d3 100644 --- a/Vocaluxe/Menu/SingNotes/CNotes.cs +++ b/Vocaluxe/Menu/SingNotes/CNotes.cs @@ -6,7 +6,7 @@ using Vocaluxe.Menu; namespace Vocaluxe.Menu.SingNotes { - class CNotes + public class CNotes { private List _Lines = new List(); diff --git a/Vocaluxe/Lib/Song/CSong.cs b/Vocaluxe/Menu/SongMenu/CSong.cs similarity index 90% rename from Vocaluxe/Lib/Song/CSong.cs rename to Vocaluxe/Menu/SongMenu/CSong.cs index 6bf91110..ebbb3202 100644 --- a/Vocaluxe/Lib/Song/CSong.cs +++ b/Vocaluxe/Menu/SongMenu/CSong.cs @@ -4,13 +4,11 @@ using System.IO; using System.Text; using System.Text.RegularExpressions; -using Vocaluxe.Base; -using Vocaluxe.Lib.Draw; using Vocaluxe.Menu; using Vocaluxe.Menu.SingNotes; using Vocaluxe.GameModes; -namespace Vocaluxe.Lib.Song +namespace Vocaluxe.Menu.SongMenu { [Flags] enum EHeaderFlags @@ -24,14 +22,14 @@ namespace Vocaluxe.Lib.Song MedleyEndBeat = 64 } - enum EMedleySource + public enum EMedleySource { None, Calculated, Tag } - struct SMedley + public struct SMedley { public EMedleySource Source; public int StartBeat; @@ -49,8 +47,9 @@ namespace Vocaluxe.Lib.Song } } - class CSong + public class CSong { + private Base _Base; private bool _CoverLoaded = false; private bool _NotesLoaded = false; private STexture _CoverTextureSmall = new STexture(-1); @@ -98,11 +97,11 @@ namespace Vocaluxe.Lib.Song if (this.CoverFileName != String.Empty) { - if (!CDataBase.GetCover(Path.Combine(this.Folder, this.CoverFileName), ref _CoverTextureSmall, CConfig.CoverSize)) - _CoverTextureSmall = CCover.NoCover; + if (!_Base.DataBase.GetCover(Path.Combine(this.Folder, this.CoverFileName), ref _CoverTextureSmall, _Base.Config.GetCoverSize())) + _CoverTextureSmall = _Base.Cover.GetNoCover(); } else - _CoverTextureSmall = CCover.NoCover; + _CoverTextureSmall = _Base.Cover.GetNoCover(); _CoverLoaded = true; } @@ -175,12 +174,14 @@ namespace Vocaluxe.Lib.Song } } - public CSong() + public CSong(Base Base) { + _Base = Base; } public CSong(CSong song) { + this._Base = song._Base; this._CoverTextureSmall = song._CoverTextureSmall; this._CoverTextureBig = song._CoverTextureBig; @@ -284,7 +285,7 @@ namespace Vocaluxe.Lib.Song this.Folder = Path.GetDirectoryName(FilePath); - foreach (string folder in CConfig.SongFolder) + foreach (string folder in _Base.Config.GetSongFolder()) { if (this.Folder.Contains(folder)) { @@ -411,7 +412,7 @@ namespace Vocaluxe.Lib.Song } else { - CLog.LogError("Can't find audio file: " + Path.Combine(this.Folder, Value)); + _Base.Log.LogError("Can't find audio file: " + Path.Combine(this.Folder, Value)); return false; } break; @@ -461,7 +462,7 @@ namespace Vocaluxe.Lib.Song if (File.Exists(Path.Combine(this.Folder, Value))) this.VideoFileName = Value; else - CLog.LogError("Can't find video file: " + Path.Combine(this.Folder, Value)); + _Base.Log.LogError("Can't find video file: " + Path.Combine(this.Folder, Value)); break; case "VIDEOGAP": @@ -517,31 +518,31 @@ namespace Vocaluxe.Lib.Song if ((HeaderFlags & EHeaderFlags.Title) == 0) { - CLog.LogError("Title tag missing: " + FilePath); + _Base.Log.LogError("Title tag missing: " + FilePath); return false; } if ((HeaderFlags & EHeaderFlags.Artist) == 0) { - CLog.LogError("Artist tag missing: " + FilePath); + _Base.Log.LogError("Artist tag missing: " + FilePath); return false; } if ((HeaderFlags & EHeaderFlags.MP3) == 0) { - CLog.LogError("MP3 tag missing: " + FilePath); + _Base.Log.LogError("MP3 tag missing: " + FilePath); return false; } if ((HeaderFlags & EHeaderFlags.BPM) == 0) { - CLog.LogError("BPM tag missing: " + FilePath); + _Base.Log.LogError("BPM tag missing: " + FilePath); return false; } if (this.Relative == EOffOn.TR_CONFIG_ON) { - CLog.LogError("Relative songs are not supported by Vocaluxe (perhaps later)! (" + FilePath + ")"); + _Base.Log.LogError("Relative songs are not supported by Vocaluxe (perhaps later)! (" + FilePath + ")"); return false; } @@ -550,7 +551,7 @@ namespace Vocaluxe.Lib.Song { if (this.Medley.StartBeat > this.Medley.EndBeat) { - CLog.LogError("MedleyStartBeat is bigger than MedleyEndBeat in file: " + FilePath); + _Base.Log.LogError("MedleyStartBeat is bigger than MedleyEndBeat in file: " + FilePath); HeaderFlags = HeaderFlags - EHeaderFlags.MedleyStartBeat - EHeaderFlags.MedleyEndBeat; } } @@ -560,7 +561,7 @@ namespace Vocaluxe.Lib.Song //PreviewStart is not set or <=0 if ((HeaderFlags & EHeaderFlags.MedleyStartBeat) != 0) //fallback to MedleyStart - this.PreviewStart = CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM); + this.PreviewStart = _Base.Game.GetTimeFromBeats(this.Medley.StartBeat, this.BPM); else //else set to 0, it will be set in FindRefrainStart this.PreviewStart = 0f; @@ -569,8 +570,8 @@ namespace Vocaluxe.Lib.Song if ((HeaderFlags & EHeaderFlags.MedleyStartBeat) != 0 && (HeaderFlags & EHeaderFlags.MedleyEndBeat) != 0) { this.Medley.Source = EMedleySource.Tag; - this.Medley.FadeInTime = CSettings.DefaultMedleyFadeInTime; - this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTime; + this.Medley.FadeInTime = _Base.Settings.GetDefaultMedleyFadeInTime(); + this.Medley.FadeOutTime = _Base.Settings.GetDefaultMedleyFadeOutTime(); } #endregion check medley tags @@ -578,7 +579,7 @@ namespace Vocaluxe.Lib.Song } catch (Exception e) { - CLog.LogError("Error reading txt header in file \"" + FilePath + "\": " + e.Message); + _Base.Log.LogError("Error reading txt header in file \"" + FilePath + "\": " + e.Message); return false; } @@ -606,7 +607,7 @@ namespace Vocaluxe.Lib.Song { if (!File.Exists(FilePath)) { - CLog.LogError("Error loading song. The file does not exist: " + FilePath); + _Base.Log.LogError("Error loading song. The file does not exist: " + FilePath); return false; } @@ -637,7 +638,7 @@ namespace Vocaluxe.Lib.Song if (sr.EndOfStream || (line.Length == 0)) { - CLog.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". The file is empty or it starts with an empty line: " + FilePath); + _Base.Log.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". The file is empty or it starts with an empty line: " + FilePath); return false; } @@ -661,7 +662,7 @@ namespace Vocaluxe.Lib.Song Player = 2; else { - CLog.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". Wrong or missing number after \"P\": " + FilePath); + _Base.Log.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". Wrong or missing number after \"P\": " + FilePath); return false; } } @@ -705,7 +706,7 @@ namespace Vocaluxe.Lib.Song { if (isNewSentence) { - CLog.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". Double sentence break: " + FilePath); + _Base.Log.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". Double sentence break: " + FilePath); return false; } @@ -731,7 +732,7 @@ namespace Vocaluxe.Lib.Song } catch (Exception e) { - CLog.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". An unhandled exception occured (" + e.Message + "): " + FilePath); + _Base.Log.LogError("Error loading song. Line No.: " + FileLineNo.ToString() + ". An unhandled exception occured (" + e.Message + "): " + FilePath); return false; } FindRefrain(); @@ -744,7 +745,7 @@ namespace Vocaluxe.Lib.Song private void ParseNote(int Player, ENoteType NoteType, int Start, int Length, int Tone, string Text) { - CNote note = new CNote(CMain.Base, Start, Length, Tone, Text, NoteType); + CNote note = new CNote(_Base, Start, Length, Tone, Text, NoteType); CLines lines = this.Notes.GetLines(Player); if (lines.LineCount == 0) @@ -810,12 +811,12 @@ namespace Vocaluxe.Lib.Song if (DuetPart1 == String.Empty) { DuetPart1 = "Part 1"; - CLog.LogError("Warning: Can't find #P1-tag for duets in \"" + this.Artist + " - " + this.Title + "\"."); + _Base.Log.LogError("Warning: Can't find #P1-tag for duets in \"" + this.Artist + " - " + this.Title + "\"."); } if (DuetPart2 == String.Empty) { DuetPart2 = "Part 2"; - CLog.LogError("Warning: Can't find #P2-tag for duets in \"" + this.Artist + " - " + this.Title + "\"."); + _Base.Log.LogError("Warning: Can't find #P2-tag for duets in \"" + this.Artist + " - " + this.Title + "\"."); } } @@ -896,7 +897,7 @@ namespace Vocaluxe.Lib.Song } // set medley vars - if (series.Count > 0 && series[longest].length > CSettings.MedleyMinSeriesLength) + if (series.Count > 0 && series[longest].length > _Base.Settings.GetMedleyMinSeriesLength()) { this.Medley.StartBeat = lines.Line[series[longest].start].FirstNoteBeat; this.Medley.EndBeat = lines.Line[series[longest].end].LastNoteBeat; @@ -904,16 +905,16 @@ namespace Vocaluxe.Lib.Song bool foundEnd = false; // set end if duration > MedleyMinDuration - if (CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + CSettings.MedleyMinDuration > - CGame.GetTimeFromBeats(this.Medley.EndBeat, this.BPM)) + if (_Base.Game.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + _Base.Settings.GetMedleyMinDuration() > + _Base.Game.GetTimeFromBeats(this.Medley.EndBeat, this.BPM)) foundEnd = true; if (!foundEnd) { for (int i = series[longest].start + 1; i < lines.LineCount - 1; i++) { - if (CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + CSettings.MedleyMinDuration > - CGame.GetTimeFromBeats(lines.Line[i].LastNoteBeat, this.BPM)) + if (_Base.Game.GetTimeFromBeats(this.Medley.StartBeat, this.BPM) + _Base.Settings.GetMedleyMinDuration() > + _Base.Game.GetTimeFromBeats(lines.Line[i].LastNoteBeat, this.BPM)) { foundEnd = true; this.Medley.EndBeat = lines.Line[i].LastNoteBeat; @@ -924,15 +925,15 @@ namespace Vocaluxe.Lib.Song if (foundEnd) { this.Medley.Source = EMedleySource.Calculated; - this.Medley.FadeInTime = CSettings.DefaultMedleyFadeInTime; - this.Medley.FadeOutTime = CSettings.DefaultMedleyFadeOutTime; + this.Medley.FadeInTime = _Base.Settings.GetDefaultMedleyFadeInTime(); + this.Medley.FadeOutTime = _Base.Settings.GetDefaultMedleyFadeOutTime(); } } if (this.PreviewStart == 0f) { if (this.Medley.Source == EMedleySource.Calculated) - this.PreviewStart = CGame.GetTimeFromBeats(this.Medley.StartBeat, this.BPM); + this.PreviewStart = _Base.Game.GetTimeFromBeats(this.Medley.StartBeat, this.BPM); } } diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs index 10de52b5..72388eaf 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuFramework.cs @@ -6,8 +6,6 @@ using System.Text; using System.Xml; using System.Xml.XPath; -using Vocaluxe.Base; -using Vocaluxe.Lib.Draw; using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu @@ -273,7 +271,7 @@ namespace Vocaluxe.Menu.SongMenu if (CHelper.GetValueFromXML(item + "/Color", navigator, ref _Theme.ColorName, String.Empty)) { - _ThemeLoaded &= CTheme.GetColor(_Theme.ColorName, SkinIndex, ref _Color); + _ThemeLoaded &= _Base.Theme.GetColor(_Theme.ColorName, SkinIndex, ref _Color); } else { @@ -444,17 +442,17 @@ namespace Vocaluxe.Menu.SongMenu if (_streams.Count > 0 && _video != -1) { - if (CVideo.VdFinished(_video) || CSound.IsFinished(_actsongstream)) + if (_Base.Video.IsFinished(_video) || _Base.Sound.IsFinished(_actsongstream)) { - CVideo.VdClose(_video); + _Base.Video.Close(_video); _video = -1; return; } - float time = CSound.GetPosition(_actsongstream); + float time = _Base.Sound.GetPosition(_actsongstream); float vtime = 0f; - CVideo.VdGetFrame(_video, ref _vidtex, time, ref vtime); + _Base.Video.GetFrame(_video, ref _vidtex, time, ref vtime); if (_VideoFadeTimer.ElapsedMilliseconds <= 3000L) { _vidtex.color.A = (_VideoFadeTimer.ElapsedMilliseconds / 3000f); @@ -477,14 +475,14 @@ namespace Vocaluxe.Menu.SongMenu { foreach (int stream in _streams) { - CSound.FadeAndStop(stream, 0f, 0.75f); + _Base.Sound.FadeAndStop(stream, 0f, 0.75f); } _streams.Clear(); - CVideo.VdClose(_video); + _Base.Video.Close(_video); _video = -1; - CDraw.RemoveTexture(ref _vidtex); + _Base.Drawing.RemoveTexture(ref _vidtex); _timer.Stop(); _timer.Reset(); @@ -510,7 +508,7 @@ namespace Vocaluxe.Menu.SongMenu if (_video != -1) { - CDraw.DrawTexture(_vidtex, new SRectF(0, 0, 1280, 720, 0)); + _Base.Drawing.DrawTexture(_vidtex, new SRectF(0, 0, 1280, 720, 0)); } } @@ -521,7 +519,7 @@ namespace Vocaluxe.Menu.SongMenu foreach (int stream in _streams) { - CSound.SetStreamVolumeMax(stream, _MaxVolume); + _Base.Sound.SetStreamVolumeMax(stream, _MaxVolume); } } @@ -582,7 +580,7 @@ namespace Vocaluxe.Menu.SongMenu Init(); if (_Theme.ColorName != String.Empty) - _Color = CTheme.GetColor(_Theme.ColorName); + _Color = _Base.Theme.GetColor(_Theme.ColorName); } public void ReloadTextures() @@ -596,10 +594,10 @@ namespace Vocaluxe.Menu.SongMenu if (!_Initialized) return; - if (Category >= CSongs.NumCategories) + if (Category >= _Base.Songs.GetNumCategories()) return; - CSongs.Category = Category; + _Base.Songs.SetCategory(Category); } protected virtual void ShowCategories() @@ -607,58 +605,58 @@ namespace Vocaluxe.Menu.SongMenu if (!_Initialized) return; - if (CSongs.Category != -1) + if (_Base.Songs.GetCurrentCategoryIndex() != -1) Reset(); - CSongs.Category = -1; + _Base.Songs.SetCategory(-1); } public void ApplyVolume() { - CSound.SetStreamVolume(_actsongstream, CConfig.PreviewMusicVolume); + _Base.Sound.SetStreamVolume(_actsongstream, _Base.Config.GetPreviewMusicVolume()); } protected void SelectSong(int nr) { - if (CSongs.Category >= 0 && (CSongs.NumVisibleSongs > 0) && (nr >= 0) && ((_actsong != nr) || (_streams.Count == 0))) + if (_Base.Songs.GetCurrentCategoryIndex() >= 0 && (_Base.Songs.GetNumVisibleSongs() > 0) && (nr >= 0) && ((_actsong != nr) || (_streams.Count == 0))) { foreach (int stream in _streams) { - CSound.FadeAndStop(stream, 0f, 1f); + _Base.Sound.FadeAndStop(stream, 0f, 1f); } _streams.Clear(); - CVideo.VdClose(_video); + _Base.Video.Close(_video); _video = -1; - CDraw.RemoveTexture(ref _vidtex); + _Base.Drawing.RemoveTexture(ref _vidtex); _actsong = nr; - if (_actsong >= CSongs.NumVisibleSongs) + if (_actsong >= _Base.Songs.GetNumVisibleSongs()) _actsong = 0; - int _stream = CSound.Load(Path.Combine(CSongs.VisibleSongs[_actsong].Folder, CSongs.VisibleSongs[_actsong].MP3FileName), true); - CSound.SetStreamVolumeMax(_stream, _MaxVolume); - CSound.SetStreamVolume(_stream, 0f); + int _stream = _Base.Sound.Load(Path.Combine(_Base.Songs.GetVisibleSong(_actsong).Folder, _Base.Songs.GetVisibleSong(_actsong).MP3FileName), true); + _Base.Sound.SetStreamVolumeMax(_stream, _MaxVolume); + _Base.Sound.SetStreamVolume(_stream, 0f); - float startposition = CSongs.VisibleSongs[_actsong].PreviewStart; + float startposition = _Base.Songs.GetVisibleSong(_actsong).PreviewStart; if (startposition == 0f) - startposition = CSound.GetLength(_stream) / 4f; + startposition = _Base.Sound.GetLength(_stream) / 4f; - CSound.SetPosition(_stream, startposition); - CSound.Play(_stream); - CSound.Fade(_stream, 100f, 3f); + _Base.Sound.SetPosition(_stream, startposition); + _Base.Sound.Play(_stream); + _Base.Sound.Fade(_stream, 100f, 3f); _streams.Add(_stream); _actsongstream = _stream; - if (CSongs.VisibleSongs[_actsong].VideoFileName != String.Empty && CConfig.VideoPreview == EOffOn.TR_CONFIG_ON) + if (_Base.Songs.GetVisibleSong(_actsong).VideoFileName != String.Empty && _Base.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON) { - _video = CVideo.VdLoad(Path.Combine(CSongs.VisibleSongs[_actsong].Folder, CSongs.VisibleSongs[_actsong].VideoFileName)); + _video = _Base.Video.Load(Path.Combine(_Base.Songs.GetVisibleSong(_actsong).Folder, _Base.Songs.GetVisibleSong(_actsong).VideoFileName)); if (_video == -1) return; - CVideo.VdSkip(_video, startposition, CSongs.VisibleSongs[_actsong].VideoGap); + _Base.Video.Skip(_video, startposition, _Base.Songs.GetVisibleSong(_actsong).VideoGap); _VideoFadeTimer.Stop(); _VideoFadeTimer.Reset(); _VideoFadeTimer.Start(); @@ -670,14 +668,14 @@ namespace Vocaluxe.Menu.SongMenu { foreach (int stream in _streams) { - CSound.FadeAndStop(stream, 0f, 0.75f); + _Base.Sound.FadeAndStop(stream, 0f, 0.75f); } _streams.Clear(); - CVideo.VdClose(_video); + _Base.Video.Close(_video); _video = -1; - CDraw.RemoveTexture(ref _vidtex); + _Base.Drawing.RemoveTexture(ref _vidtex); _timer.Stop(); _timer.Reset(); diff --git a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs index 0b0880d8..33392750 100644 --- a/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs +++ b/Vocaluxe/Menu/SongMenu/CSongMenuTileBoard.cs @@ -6,7 +6,7 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; +using Vocaluxe.Menu.SongMenu; using Vocaluxe.PartyModes; namespace Vocaluxe.Menu.SongMenu diff --git a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs index 16d0d3bd..86d4a96a 100644 --- a/Vocaluxe/Screens/CPopupScreenPlayerControl.cs +++ b/Vocaluxe/Screens/CPopupScreenPlayerControl.cs @@ -8,7 +8,7 @@ using Vocaluxe.Base; using Vocaluxe.GameModes; using Vocaluxe.Lib.Draw; using Vocaluxe.Menu; -using Vocaluxe.Lib.Song; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Screens { diff --git a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs index 76624af1..882fae0b 100644 --- a/Vocaluxe/Screens/CPopupScreenVolumeControl.cs +++ b/Vocaluxe/Screens/CPopupScreenVolumeControl.cs @@ -8,7 +8,7 @@ using Vocaluxe.Base; using Vocaluxe.GameModes; using Vocaluxe.Lib.Draw; using Vocaluxe.Menu; -using Vocaluxe.Lib.Song; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Screens { diff --git a/Vocaluxe/Screens/CScreenHighscore.cs b/Vocaluxe/Screens/CScreenHighscore.cs index 06cb2c6d..7ff5e97d 100644 --- a/Vocaluxe/Screens/CScreenHighscore.cs +++ b/Vocaluxe/Screens/CScreenHighscore.cs @@ -5,8 +5,8 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.GameModes; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Screens { diff --git a/Vocaluxe/Screens/CScreenLoad.cs b/Vocaluxe/Screens/CScreenLoad.cs index 77f3cab4..f7e28732 100644 --- a/Vocaluxe/Screens/CScreenLoad.cs +++ b/Vocaluxe/Screens/CScreenLoad.cs @@ -9,8 +9,8 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Screens { diff --git a/Vocaluxe/Screens/CScreenScore.cs b/Vocaluxe/Screens/CScreenScore.cs index 7f0701fc..f2f800be 100644 --- a/Vocaluxe/Screens/CScreenScore.cs +++ b/Vocaluxe/Screens/CScreenScore.cs @@ -8,7 +8,7 @@ using Vocaluxe.Base; using Vocaluxe.Menu; using Vocaluxe.GameModes; -using Vocaluxe.Lib.Song; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Screens { diff --git a/Vocaluxe/Screens/CScreenSing.cs b/Vocaluxe/Screens/CScreenSing.cs index f4567702..4d4165a8 100644 --- a/Vocaluxe/Screens/CScreenSing.cs +++ b/Vocaluxe/Screens/CScreenSing.cs @@ -10,8 +10,7 @@ using Vocaluxe.Base; using Vocaluxe.Lib.Draw; using Vocaluxe.Menu; using Vocaluxe.Menu.SingNotes; - -using Vocaluxe.Lib.Song; +using Vocaluxe.Menu.SongMenu; namespace Vocaluxe.Screens { diff --git a/Vocaluxe/Screens/CScreenSong.cs b/Vocaluxe/Screens/CScreenSong.cs index b6fab24a..8b519091 100644 --- a/Vocaluxe/Screens/CScreenSong.cs +++ b/Vocaluxe/Screens/CScreenSong.cs @@ -9,7 +9,6 @@ using System.Windows.Forms; using Vocaluxe.Base; using Vocaluxe.GameModes; using Vocaluxe.Lib.Draw; -using Vocaluxe.Lib.Song; using Vocaluxe.Menu; using Vocaluxe.Menu.SongMenu; using Vocaluxe.PartyModes; @@ -814,7 +813,7 @@ namespace Vocaluxe.Screens id = CSongs.VisibleSongs[song].ID; } - int visibleID = Array.FindIndex(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); + int visibleID = Array.FindIndex(CSongs.VisibleSongs, element => element.Artist.StartsWith(Letter.ToString(), StringComparison.OrdinalIgnoreCase)); if (visibleID > -1) { id = visibleID; diff --git a/Vocaluxe/Vocaluxe.csproj b/Vocaluxe/Vocaluxe.csproj index cd0d81f3..f2f7cb81 100644 --- a/Vocaluxe/Vocaluxe.csproj +++ b/Vocaluxe/Vocaluxe.csproj @@ -210,7 +210,7 @@ - +