From ded087967dd3569b551da915d94168153486c78c Mon Sep 17 00:00:00 2001 From: Alexander Eckart Date: Thu, 13 Dec 2012 23:00:52 +0100 Subject: [PATCH] removed namespace Base from CNotes, some simplifications --- Vocaluxe/Base/CGame.cs | 10 +++++----- Vocaluxe/Base/CGraphics.cs | 6 ++---- Vocaluxe/Base/CMain.cs | 12 ++++++++++++ Vocaluxe/Lib/Song/CSong.cs | 2 +- Vocaluxe/Menu/CMenu.cs | 7 +++---- Vocaluxe/Menu/IMenu.cs | 6 ++++-- Vocaluxe/Menu/SingNotes/CNotes.cs | 24 +++++++++++++----------- 7 files changed, 40 insertions(+), 27 deletions(-) diff --git a/Vocaluxe/Base/CGame.cs b/Vocaluxe/Base/CGame.cs index c640148a..eb7a51e2 100644 --- a/Vocaluxe/Base/CGame.cs +++ b/Vocaluxe/Base/CGame.cs @@ -315,7 +315,7 @@ namespace Vocaluxe.Base { CNote nt = _Player[p].SingLine[Line].LastNote; if (notes[Note].StartBeat == beat || nt.EndBeat + 1 != beat || nt.Tone != Tone) - _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType)); + _Player[p].SingLine[Line].AddNote(new CNote(CMain.Base, beat, 1, Tone, String.Empty, true, notes[Note].NoteType)); else { _Player[p].SingLine[Line].IncLastNoteLength(); @@ -323,7 +323,7 @@ namespace Vocaluxe.Base } else { - _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, Tone, String.Empty, true, notes[Note].NoteType)); + _Player[p].SingLine[Line].AddNote(new CNote(CMain.Base, beat, 1, Tone, String.Empty, true, notes[Note].NoteType)); } _Player[p].SingLine[Line].LastNote.IsPerfect(notes[Note]); @@ -335,7 +335,7 @@ namespace Vocaluxe.Base { CNote nt = _Player[p].SingLine[Line].LastNote; if (nt.EndBeat + 1 != beat || nt.Hit) - _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); + _Player[p].SingLine[Line].AddNote(new CNote(CMain.Base, beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); else { if (nt.Tone == TonePlayer && nt.EndBeat + 1 == beat) @@ -344,13 +344,13 @@ namespace Vocaluxe.Base } else { - _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); + _Player[p].SingLine[Line].AddNote(new CNote(CMain.Base, beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); } } } else { - _Player[p].SingLine[Line].AddNote(new CNote(beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); + _Player[p].SingLine[Line].AddNote(new CNote(CMain.Base, beat, 1, TonePlayer, String.Empty, false, ENoteType.Freestyle)); } } diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 0f5e584d..75678858 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -280,16 +280,14 @@ namespace Vocaluxe.Menu for (int i = 0; i < _Screens.Count; i++) { CLog.StartBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]); - _Screens[i].Initialize(CMain.Config, CMain.Settings, CMain.Theme, CMain.Helper, CMain.Log, CMain.BackgroundMusic, CMain.Draw, - CMain.Graphics, CMain.Fonts, CMain.Language, CMain.Game, CMain.Profiles); + _Screens[i].Initialize(CMain.Base); _Screens[i].LoadTheme(); CLog.StopBenchmark(1, "Load Theme " + Enum.GetNames(typeof(EScreens))[i]); } for (int i = 0; i < _PopupScreens.Count; i++) { - _PopupScreens[i].Initialize(CMain.Config, CMain.Settings, CMain.Theme, CMain.Helper, CMain.Log, CMain.BackgroundMusic, CMain.Draw, - CMain.Graphics, CMain.Fonts, CMain.Language, CMain.Game, CMain.Profiles); + _PopupScreens[i].Initialize(CMain.Base); _PopupScreens[i].LoadTheme(); } } diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 328510fa..f226d8ff 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -21,6 +21,8 @@ namespace Vocaluxe.Base public static ILanguage Language = new BLanguage(); public static IGame Game = new BGame(); public static IProfiles Profiles = new BProfiles(); + + public static Menu.Base Base = new Menu.Base(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, Game, Profiles); } class BConfig : IConfig @@ -89,6 +91,16 @@ namespace Vocaluxe.Base { return CSettings.GameState; } + + public int GetToneMin() + { + return CSettings.ToneMin; + } + + public int GetToneMax() + { + return CSettings.ToneMax; + } } class BTheme : ITheme diff --git a/Vocaluxe/Lib/Song/CSong.cs b/Vocaluxe/Lib/Song/CSong.cs index f3a4d328..6bf91110 100644 --- a/Vocaluxe/Lib/Song/CSong.cs +++ b/Vocaluxe/Lib/Song/CSong.cs @@ -744,7 +744,7 @@ namespace Vocaluxe.Lib.Song private void ParseNote(int Player, ENoteType NoteType, int Start, int Length, int Tone, string Text) { - CNote note = new CNote(Start, Length, Tone, Text, NoteType); + CNote note = new CNote(CMain.Base, Start, Length, Tone, Text, NoteType); CLines lines = this.Notes.GetLines(Player); if (lines.LineCount == 0) diff --git a/Vocaluxe/Menu/CMenu.cs b/Vocaluxe/Menu/CMenu.cs index 22f4952c..0785ed63 100644 --- a/Vocaluxe/Menu/CMenu.cs +++ b/Vocaluxe/Menu/CMenu.cs @@ -93,13 +93,12 @@ namespace Vocaluxe.Menu } public CMenu() - { + { } - public void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, - IGraphics Graphics, IFonts Fonts, ILanguage Language, IGame Game, IProfiles Profiles) + public void Initialize(Base Base) { - _Base = new Base(Config, Settings, Theme, Helper, Log, BackgroundMusic, Draw, Graphics, Fonts, Language, Game, Profiles); + _Base = Base; Init(); } diff --git a/Vocaluxe/Menu/IMenu.cs b/Vocaluxe/Menu/IMenu.cs index 87f23fee..e86bd4c1 100644 --- a/Vocaluxe/Menu/IMenu.cs +++ b/Vocaluxe/Menu/IMenu.cs @@ -10,8 +10,7 @@ namespace Vocaluxe.Menu { interface IMenu { - void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, - IGraphics Graphics, IFonts Fonts, ILanguage Language, IGame Game, IProfiles Profiles); + void Initialize(Base Base); void LoadTheme(); void SaveTheme(); @@ -64,6 +63,9 @@ namespace Vocaluxe.Menu float GetZNear(); EGameState GetGameState(); + + int GetToneMin(); + int GetToneMax(); } public interface ITheme diff --git a/Vocaluxe/Menu/SingNotes/CNotes.cs b/Vocaluxe/Menu/SingNotes/CNotes.cs index 578c75b0..80685b2e 100644 --- a/Vocaluxe/Menu/SingNotes/CNotes.cs +++ b/Vocaluxe/Menu/SingNotes/CNotes.cs @@ -2,7 +2,6 @@ using System.Collections.Generic; using System.Text; -using Vocaluxe.Base; using Vocaluxe.Menu; namespace Vocaluxe.Menu.SingNotes @@ -84,6 +83,7 @@ namespace Vocaluxe.Menu.SingNotes public class CNote { + private Base _Base; private int _StartBeat; private int _Duration; private int _Tone; @@ -93,8 +93,9 @@ namespace Vocaluxe.Menu.SingNotes private bool _Perfect; // for drawing perfect note effect #region Contructors - public CNote() + public CNote(Base Base) { + _Base = Base; StartBeat = 0; Duration = 1; Tone = 0; @@ -106,6 +107,7 @@ namespace Vocaluxe.Menu.SingNotes public CNote(CNote note) { + _Base = note._Base; _StartBeat = note._StartBeat; _Duration = note._Duration; _Tone = note._Tone; @@ -115,8 +117,8 @@ namespace Vocaluxe.Menu.SingNotes _Perfect = note._Perfect; } - public CNote(int StartBeat, int Duration, int Tone, string Text) - : this() + public CNote(Base Base, int StartBeat, int Duration, int Tone, string Text) + : this(Base) { this.StartBeat = StartBeat; this.Duration = Duration; @@ -125,8 +127,8 @@ namespace Vocaluxe.Menu.SingNotes this.Text = Text; } - public CNote(int StartBeat, int Duration, int Tone, string Text, bool Hit) - : this() + public CNote(Base Base, int StartBeat, int Duration, int Tone, string Text, bool Hit) + : this(Base) { this.StartBeat = StartBeat; this.Duration = Duration; @@ -136,14 +138,14 @@ namespace Vocaluxe.Menu.SingNotes this.Hit = Hit; } - public CNote(int StartBeat, int Duration, int Tone, string Text, ENoteType NoteType) - : this(StartBeat, Duration, Tone, Text) + public CNote(Base Base, int StartBeat, int Duration, int Tone, string Text, ENoteType NoteType) + : this(Base, StartBeat, Duration, Tone, Text) { this.NoteType = NoteType; } - public CNote(int StartBeat, int Duration, int Tone, string Text, bool Hit, ENoteType NoteType) - : this(StartBeat, Duration, Tone, Text) + public CNote(Base Base, int StartBeat, int Duration, int Tone, string Text, bool Hit, ENoteType NoteType) + : this(Base, StartBeat, Duration, Tone, Text) { this.NoteType = NoteType; this.Hit = Hit; @@ -192,7 +194,7 @@ namespace Vocaluxe.Menu.SingNotes get { return _Tone; } set { - if ((value >= CSettings.ToneMin) && (value <= CSettings.ToneMax)) + if ((value >= _Base.Settings.GetToneMin()) && (value <= _Base.Settings.GetToneMax())) _Tone = value; } }