First step to eliminate the namespace Vocaluxe.Base from all Vocaluxe.Menu classe. There is still a lot of work...

This commit is contained in:
Alexander Eckart committed 2012-12-13 18:19:08 +01:00
1 parent 7676840932
commit 79946a17c5
47 files changed
+426 -627

No files matched your search

+1 -3
View File
@@ -12,6 +12,7 @@ using OpenTK.Platform;
using Vocaluxe.Lib.Sound;
using Vocaluxe.Lib.Webcam;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
@@ -1098,8 +1099,5 @@ namespace Vocaluxe.Base
}
}
}
}
}
+1
View File
@@ -6,6 +6,7 @@ using System.Xml;
using System.Xml.XPath;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
+1
View File
@@ -21,6 +21,7 @@ using Community.CsharpSqlite;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Song;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
+2
View File
@@ -280,12 +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);
_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);
_PopupScreens[i].LoadTheme();
}
}
+1
View File
@@ -4,6 +4,7 @@ using System.Text;
using Vocaluxe.Lib.Input;
using Vocaluxe.Lib.Input.WiiMote;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
+2
View File
@@ -6,6 +6,8 @@ using System.Text;
using System.Xml;
using System.Xml.XPath;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
struct SLanguage
+1
View File
@@ -7,6 +7,7 @@ using System.Xml.XPath;
using Vocaluxe.Lib.Song;
using Vocaluxe.Lib.Playlist;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
+1
View File
@@ -6,6 +6,7 @@ using System.Xml;
using System.Xml.XPath;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
+2 -7
View File
@@ -3,15 +3,10 @@ using System.Collections.Generic;
using System.IO;
using System.Text;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
public enum EGameState
{
Start,
Normal,
EditTheme
}
enum ERevision
{
Alpha,
+1 -405
View File
@@ -10,130 +10,10 @@ using System.Xml;
using System.Xml.XPath;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
[Flags]
public enum EModifier
{
None,
Shift,
Alt,
Ctrl
}
public enum ESender
{
Mouse,
Keyboard,
WiiMote,
Gamepad
}
public struct KeyEvent
{
public ESender Sender;
public bool ModALT;
public bool ModSHIFT;
public bool ModCTRL;
public bool KeyPressed;
public bool Handled;
public Keys Key;
public Char Unicode;
public EModifier Mod;
public KeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
{
Sender = sender;
ModALT = alt;
ModSHIFT = shift;
ModCTRL = ctrl;
KeyPressed = pressed;
Unicode = unicode;
Key = key;
Handled = false;
EModifier mALT = EModifier.None;
EModifier mSHIFT = EModifier.None;
EModifier mCTRL = EModifier.None;
if (alt)
mALT = EModifier.Alt;
if (shift)
mSHIFT = EModifier.Shift;
if (ctrl)
mCTRL = EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mALT | mSHIFT | mCTRL;
}
}
public struct MouseEvent
{
public ESender Sender;
public int X;
public int Y;
public bool LB; //left button click
public bool LD; //left button double click
public bool RB; //right button click
public bool MB; //middle button click
public bool LBH; //left button hold (when moving)
public bool RBH; //right button hold (when moving)
public bool MBH; //middle button hold (when moving)
public bool ModALT;
public bool ModSHIFT;
public bool ModCTRL;
public EModifier Mod;
public int Wheel;
public MouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{
Sender = sender;
X = x;
Y = y;
LB = lb;
LD = ld;
RB = rb;
MB = mb;
LBH = lbh;
RBH = rbh;
MBH = mbh;
ModALT = alt;
ModSHIFT = shift;
ModCTRL = ctrl;
EModifier mALT = EModifier.None;
EModifier mSHIFT = EModifier.None;
EModifier mCTRL = EModifier.None;
if (alt)
mALT = EModifier.Alt;
if (shift)
mSHIFT = EModifier.Shift;
if (ctrl)
mCTRL = EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mALT | mSHIFT | mCTRL;
Wheel = wheel;
}
}
static class CTime
{
private static Stopwatch _Stopwatch = new Stopwatch();
@@ -469,290 +349,6 @@ namespace Vocaluxe.Base
}
class CHelper
{
public static int TryReadInt(StreamReader sr)
{
char chr = '0';
string value = String.Empty;
try
{
chr = (char)sr.Peek();
while ((chr.CompareTo(' ') != 0) && ((int)chr != 19) && ((int)chr != 16) && ((int)chr != 13))
{
chr = (char)sr.Read();
value += chr.ToString();
chr = (char)sr.Peek();
}
}
catch (Exception)
{
return 0;
}
int result = 0;
int.TryParse(value, out result);
return result;
}
public static void SetRect(RectangleF Bounds, ref RectangleF Rect, float RectAspect, EAspect Aspect)
{
float rW = Bounds.Right - Bounds.Left;
float rH = Bounds.Bottom - Bounds.Top;
float rA = rW / rH;
float ScaledWidth = rW;
float ScaledHeight = rH;
switch (Aspect)
{
case EAspect.Crop:
if (rA >= RectAspect)
{
ScaledWidth = rW;
ScaledHeight = rH * rA / RectAspect;
}
else
{
ScaledHeight = rH;
ScaledWidth = rW * RectAspect / rA;
}
break;
case EAspect.LetterBox:
if (RectAspect >= 1)
{
ScaledWidth = rW;
ScaledHeight = rH * rA / RectAspect;
}
else
{
ScaledHeight = rH;
ScaledWidth = rW * RectAspect / rA;
}
break;
default:
ScaledWidth = rW;
ScaledHeight = rH;
break;
}
float Left = (rW - ScaledWidth) / 2 + Bounds.Left;
float Rigth = Left + ScaledWidth;
float Upper = (rH - ScaledHeight) / 2 + Bounds.Top;
float Lower = Upper + ScaledHeight;
Rect = new RectangleF(Left, Upper, Rigth - Left, Lower - Upper);
}
public static bool TryGetEnumValueFromXML<T>(string Cast, XPathNavigator Navigator, ref T value)
where T : struct
{
string val = String.Empty;
if (GetValueFromXML(Cast, Navigator, ref val, Enum.GetName(typeof(T), value)))
{
TryParse<T>(val, out value, true);
return true;
}
return false;
}
public static bool TryGetIntValueFromXML(string Cast, XPathNavigator Navigator, ref int value)
{
string val = String.Empty;
if (GetValueFromXML(Cast, Navigator, ref val, value.ToString()))
{
int res = 0;
if (int.TryParse(val, out res))
{
value = res;
return true;
}
}
return false;
}
public static bool TryGetFloatValueFromXML(string Cast, XPathNavigator Navigator, ref float value)
{
string val = String.Empty;
if (GetValueFromXML(Cast, Navigator, ref val, value.ToString()))
{
float res = 0;
if (TryParse(val, out res))
{
value = res;
return true;
}
}
return false;
}
public static bool GetValueFromXML(string Cast, XPathNavigator Navigator, ref string Value, string DefaultValue)
{
XPathNodeIterator iterator;
int results = 0;
string val = string.Empty;
try
{
Navigator.MoveToFirstChild();
iterator = Navigator.Select(Cast);
while (iterator.MoveNext())
{
val = iterator.Current.Value;
results++;
}
}
catch (Exception)
{
results = 0;
}
if ((results == 0) || (results > 1))
{
Value = DefaultValue;
return false;
}
else
{
Value = val;
return true;
}
}
public static List<string> GetValuesFromXML(string Cast, XPathNavigator Navigator)
{
List<string> values = new List<string>();
try
{
Navigator.MoveToRoot();
Navigator.MoveToFirstChild();
Navigator.MoveToFirstChild();
while (Navigator.Name != Cast)
Navigator.MoveToNext();
Navigator.MoveToFirstChild();
values.Add(Navigator.LocalName);
while(Navigator.MoveToNext())
values.Add(Navigator.LocalName);
}
catch (Exception)
{
}
return values;
}
public static bool ItemExistsInXML(string Cast, XPathNavigator Navigator)
{
XPathNodeIterator iterator;
int results = 0;
try
{
Navigator.MoveToFirstChild();
iterator = Navigator.Select(Cast);
while (iterator.MoveNext())
results++;
}
catch (Exception)
{
results = 0;
}
if (results == 0)
return false;
return true;
}
public List<string> ListFiles(string path, string cast)
{
return ListFiles(path, cast, false, false);
}
public List<string> ListFiles(string path, string cast, bool recursive)
{
return ListFiles(path, cast, recursive, false);
}
public List<string> ListFiles(string path, string cast, bool recursive, bool fullpath)
{
List<string> files = new List<string>();
DirectoryInfo dir = new DirectoryInfo(path);
try
{
foreach (FileInfo file in dir.GetFiles(cast))
{
if (!fullpath)
files.Add(file.Name);
else
//files.Add(Path.Combine(file.DirectoryName, file.Name));
files.Add(file.FullName);
}
if (recursive)
{
foreach (DirectoryInfo di in dir.GetDirectories())
{
files.AddRange(ListFiles(di.FullName, cast, recursive, fullpath));
}
}
} catch (Exception)
{
}
return files;
}
public static bool TryParse<T>(string value, out T result)
where T : struct
{
return TryParse<T>(value, out result, false);
}
public static bool TryParse<T>(string value, out T result, bool ignoreCase)
where T : struct
{
result = default(T);
try
{
result = (T)Enum.Parse(typeof(T), value, ignoreCase);
return true;
}
catch { }
return false;
}
public static bool TryParse(string value, out float result)
{
value = value.Replace(',', '.');
return float.TryParse(value, NumberStyles.AllowDecimalPoint | NumberStyles.AllowLeadingSign, NumberFormatInfo.InvariantInfo, out result);
}
public static bool IsInBounds(SRectF bounds, MouseEvent MouseEvent)
{
return IsInBounds(bounds, MouseEvent.X, MouseEvent.Y);
}
public static bool IsInBounds(SRectF bounds, int x, int y)
{
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)
+1 -1
View File
@@ -4,7 +4,7 @@ using System.Diagnostics;
using System.Drawing;
using System.Text;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
using Vocaluxe.Lib.Video;
namespace Vocaluxe.Base
+3 -1
View File
@@ -1,10 +1,12 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using Vocaluxe.Lib.Webcam;
using Vocaluxe.Lib.Draw;
using System.Drawing;
using Vocaluxe.Menu;
namespace Vocaluxe.Base
{
-116
View File
@@ -8,122 +8,6 @@ using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Draw
{
#region Structs
public struct SColorF
{
public float R;
public float G;
public float B;
public float A;
public SColorF(float r, float g, float b, float a)
{
R = r;
G = g;
B = b;
A = a;
}
public SColorF(SColorF Color)
{
R = Color.R;
G = Color.G;
B = Color.B;
A = Color.A;
}
}
public struct SRectF
{
public float X;
public float Y;
public float W;
public float H;
public float Z;
public float Rotation; //0..360°
public SRectF(float x, float y, float w, float h, float z)
{
X = x;
Y = y;
W = w;
H = h;
Z = z;
Rotation = 0f;
}
public SRectF(SRectF rect)
{
X = rect.X;
Y = rect.Y;
W = rect.W;
H = rect.H;
Z = rect.Z;
Rotation = 0f;
}
}
public struct SPoint3f
{
public float X;
public float Y;
public float Z;
}
public struct SPoint3
{
public int X;
public int Y;
public int Z;
}
public struct STexture
{
public int index;
public int PBO;
public int ID;
public string TexturePath;
public float width;
public float height;
public SRectF rect;
public float w2; //power of 2 width
public float h2; //power of 2 height
public float width_ratio;
public float height_ratio;
public SColorF color;
public STexture(int Index)
{
index = Index;
PBO = 0;
ID = -1;
TexturePath = String.Empty;
width = 1f;
height = 1f;
rect = new SRectF(0f, 0f, 1f, 1f, 0f);
w2 = 2f;
h2 = 2f;
width_ratio = 0.5f;
height_ratio = 0.5f;
color = new SColorF(1f, 1f, 1f, 1f);
}
}
#endregion Structs
enum EAspect
{
Crop,
LetterBox,
Stretch
}
interface IDraw
{
bool Init();
+1
View File
@@ -5,6 +5,7 @@ using System.Drawing;
using System.Text;
using Vocaluxe.Base;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Input
{
+1
View File
@@ -7,6 +7,7 @@ using System.Text;
using System.Threading;
using Vocaluxe.Base;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Input.WiiMote
{
+1
View File
@@ -10,6 +10,7 @@ using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Input;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Input.WiiMote
{
+1
View File
@@ -8,6 +8,7 @@ using System.Xml.XPath;
using Vocaluxe.Base;
using Vocaluxe.GameModes;
using Vocaluxe.Lib.Song;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Playlist
+1 -1
View File
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Video
{
@@ -9,6 +9,7 @@ using System.Threading;
using Vocaluxe.Base;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Lib.Video.Acinerella;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Video
{
+1
View File
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Text;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Video
{
+2
View File
@@ -10,6 +10,8 @@ using System.Runtime.InteropServices;
using Vocaluxe.Lib.Draw;
using System.Threading;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Webcam
{
class CAForgeNet : IWebcam
+2
View File
@@ -4,6 +4,8 @@ using System.Text;
using Vocaluxe.Lib.Draw;
using System.Drawing;
using Vocaluxe.Menu;
namespace Vocaluxe.Lib.Webcam
{
struct SWebcamDevice
+77 -66
View File
@@ -8,7 +8,7 @@ using System.Windows.Forms;
using System.Xml;
using System.Xml.XPath;
using Vocaluxe.Base;
//using Vocaluxe.Base;
using Vocaluxe.Lib.Draw;
using Vocaluxe.Menu;
using Vocaluxe.Menu.SingNotes;
@@ -76,6 +76,15 @@ namespace Vocaluxe.Menu
protected SRectF _ScreenArea;
private IConfig _Config;
private ISettings _Settings;
private ITheme _Theme;
private IHelper _Helper;
private ILog _Log;
private IBackgroundMusic _BackgroundMusic;
private IDrawing _Draw;
private IGraphics _Graphics;
public SRectF ScreenArea
{
get { return _ScreenArea; }
@@ -92,7 +101,20 @@ namespace Vocaluxe.Menu
}
public CMenu()
{
}
public void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, IGraphics Graphics)
{
_Config = Config;
_Settings = Settings;
_Theme = Theme;
_Helper = Helper;
_Log = Log;
_BackgroundMusic = BackgroundMusic;
_Draw = Draw;
_Graphics = Graphics;
Init();
}
@@ -132,8 +154,8 @@ namespace Vocaluxe.Menu
_MouseDY = 0;
_Active = false;
_ScreenArea = new SRectF(0f, 0f, CSettings.iRenderW, CSettings.iRenderH, 0f);
_ScreenArea = new SRectF(0f, 0f, _Settings.GetRenderW(), _Settings.GetRenderH(), 0f);
_ThemeName = String.Empty;
_ThemeBackgrounds = null;
_ThemeStatics = null;
@@ -146,12 +168,11 @@ namespace Vocaluxe.Menu
_ThemeNameSelections = null;
_ThemeEqualizers = null;
_ThemePlaylists = null;
}
#region ThemeHandler
public virtual void LoadTheme()
{
string file = Path.Combine(CTheme.GetThemeScreensPath(), _ThemeName + ".xml");
string file = Path.Combine(_Theme.GetThemeScreensPath(), _ThemeName + ".xml");
XPathDocument xPathDoc = null;
XPathNavigator navigator = null;
@@ -172,14 +193,14 @@ namespace Vocaluxe.Menu
if (xPathDoc != null)
xPathDoc = null;
CLog.LogError("Error loading theme file " + file + ": " + e.Message);
_Log.LogError("Error loading theme file " + file + ": " + e.Message);
}
bool VersionCheck = false;
if (loaded)
VersionCheck = CheckVersion(_ScreenVersion, navigator);
int SkinIndex = CTheme.GetSkinIndex();
int SkinIndex = _Theme.GetSkinIndex();
if (loaded && VersionCheck && SkinIndex != -1)
{
@@ -196,7 +217,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load Background \"" + _ThemeBackgrounds[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load Background \"" + _ThemeBackgrounds[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -212,7 +233,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load Static \"" + _ThemeStatics[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load Static \"" + _ThemeStatics[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -228,7 +249,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load Text \"" + _ThemeTexts[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load Text \"" + _ThemeTexts[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -244,7 +265,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load Button \"" + _ThemeButtons[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load Button \"" + _ThemeButtons[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -260,7 +281,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load SelectSlide \"" + _ThemeSelectSlides[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load SelectSlide \"" + _ThemeSelectSlides[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -276,7 +297,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load SongMenu \"" + _ThemeSongMenus[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load SongMenu \"" + _ThemeSongMenus[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -292,7 +313,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load Lyric \"" + _ThemeLyrics[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load Lyric \"" + _ThemeLyrics[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -308,7 +329,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load SingBar \"" + _ThemeSingNotes[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load SingBar \"" + _ThemeSingNotes[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -324,7 +345,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load NameSelection \"" + _ThemeNameSelections[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load NameSelection \"" + _ThemeNameSelections[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -340,7 +361,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load equalizer \"" + _ThemeEqualizers[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -356,7 +377,7 @@ namespace Vocaluxe.Menu
}
else
{
CLog.LogError("Can't load Playlist \"" + _ThemePlaylists[i] + "\" in screen " + _ThemeName);
_Log.LogError("Can't load Playlist \"" + _ThemePlaylists[i] + "\" in screen " + _ThemeName);
}
}
}
@@ -374,7 +395,7 @@ namespace Vocaluxe.Menu
settings.Encoding = Encoding.UTF8;
settings.ConformanceLevel = ConformanceLevel.Document;
string file = Path.Combine(CTheme.GetThemeScreensPath(), _ThemeName + ".xml");
string file = Path.Combine(_Theme.GetThemeScreensPath(), _ThemeName + ".xml");
XmlWriter writer = XmlWriter.Create(file, settings);
writer.WriteStartDocument();
@@ -738,7 +759,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Background Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Background Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -751,7 +772,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Statics Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Statics Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -764,7 +785,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Text Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Text Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -777,7 +798,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Button Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Button Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -790,7 +811,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find SongMenu Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find SongMenu Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -803,7 +824,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Lyric Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Lyric Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -816,7 +837,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find SelectSlide Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find SelectSlide Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -829,7 +850,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find SingBar Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find SingBar Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -842,7 +863,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find NameSelection Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find NameSelection Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -855,7 +876,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Equalizer Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -868,7 +889,7 @@ namespace Vocaluxe.Menu
}
catch (Exception)
{
CLog.LogError("Can't find Playlist Element \"" + key + "\" in Screen " + _ThemeName);
_Log.LogError("Can't find Playlist Element \"" + key + "\" in Screen " + _ThemeName);
throw;
}
}
@@ -878,7 +899,7 @@ namespace Vocaluxe.Menu
#region MenuHandler
public virtual bool HandleInput(KeyEvent KeyEvent)
{
if (!CSettings.TabNavigation)
if (!_Settings.IsTabNavigation())
{
if (KeyEvent.Key == Keys.Left)
{
@@ -917,35 +938,25 @@ namespace Vocaluxe.Menu
if (KeyEvent.Key == Keys.Right)
NextElement();
}
if (!CBackgroundMusic.Disabled)
if (_BackgroundMusic.IsDisabled())
{
if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Add || KeyEvent.Key == Keys.PageUp))
{
CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume + 5;
if (CConfig.BackgroundMusicVolume > 100)
CConfig.BackgroundMusicVolume = 100;
CConfig.SaveConfig();
}
_Config.SetBackgroundMusicVolume(_Config.GetBackgroundMusicVolume() + 5);
else if (KeyEvent.ModSHIFT && (KeyEvent.Key == Keys.Subtract || KeyEvent.Key == Keys.PageDown))
{
CConfig.BackgroundMusicVolume = CConfig.BackgroundMusicVolume - 5;
if (CConfig.BackgroundMusicVolume < 0)
CConfig.BackgroundMusicVolume = 0;
CConfig.SaveConfig();
}
_Config.SetBackgroundMusicVolume(_Config.GetBackgroundMusicVolume() - 5);
else if (KeyEvent.Key == Keys.MediaNextTrack)
CBackgroundMusic.Next();
_BackgroundMusic.Next();
else if (KeyEvent.Key == Keys.MediaPreviousTrack)
CBackgroundMusic.Previous();
_BackgroundMusic.Previous();
else if (KeyEvent.Key == Keys.MediaPlayPause)
{
if (CBackgroundMusic.Playing)
CBackgroundMusic.Pause();
if (_BackgroundMusic.IsPlaying())
_BackgroundMusic.Pause();
else
CBackgroundMusic.Play();
_BackgroundMusic.Play();
}
CBackgroundMusic.ApplyVolume();
_BackgroundMusic.ApplyVolume();
}
return true;
@@ -1356,10 +1367,10 @@ namespace Vocaluxe.Menu
public void SelectByMouse(int x, int y)
{
float z = CSettings.zFar;
float z = _Settings.GetZFar();
for (int i = 0; i < _Interactions.Count; i++)
{
if ((CSettings.GameState == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i)))
if ((_Settings.GetGameState() == EGameState.EditTheme) || (!_Interactions[i].ThemeEditorOnly && _IsVisible(i)))
{
if (_IsMouseOver(x, y, _Interactions[i]))
{
@@ -1410,7 +1421,7 @@ namespace Vocaluxe.Menu
return true;
break;
case EType.TText:
RectangleF bounds = CDraw.GetTextBounds(_Texts[interact.Num]);
RectangleF bounds = _Draw.GetTextBounds(_Texts[interact.Num]);
if (CHelper.IsInBounds(new SRectF(_Texts[interact.Num].X, _Texts[interact.Num].Y, bounds.Width, bounds.Height, _Texts[interact.Num].Z), x, y))
return true;
break;
@@ -1461,7 +1472,7 @@ namespace Vocaluxe.Menu
case EType.TPlaylist:
return _Playlists[interact.Num].Rect.Z;
}
return CSettings.zFar;
return _Settings.GetZFar();
}
private float _GetZValue(int interaction)
@@ -1496,13 +1507,13 @@ namespace Vocaluxe.Menu
return _Playlists[_Interactions[interaction].Num].Rect.Z;
}
return CSettings.zFar;
return _Settings.GetZFar();
}
private void _NextInteraction()
{
_UnsetSelected();
if (CSettings.GameState != EGameState.EditTheme)
if (_Settings.GetGameState() != EGameState.EditTheme)
{
bool found = false;
int start = _Selection;
@@ -1529,7 +1540,7 @@ namespace Vocaluxe.Menu
private void _PrevInteraction()
{
_UnsetSelected();
if (CSettings.GameState != EGameState.EditTheme)
if (_Settings.GetGameState() != EGameState.EditTheme)
{
bool found = false;
int start = _Selection;
@@ -1676,13 +1687,13 @@ namespace Vocaluxe.Menu
switch (Key.Key)
{
case Keys.Up:
actualRect = new SRectF(actualRect.X, CSettings.iRenderH, 1, 1, actualRect.Z);
actualRect = new SRectF(actualRect.X, _Settings.GetRenderH(), 1, 1, actualRect.Z);
break;
case Keys.Down:
actualRect = new SRectF(actualRect.X, 0, 1, 1, actualRect.Z);
break;
case Keys.Left:
actualRect = new SRectF(CSettings.iRenderW, actualRect.Y, 1, 1, actualRect.Z);
actualRect = new SRectF(_Settings.GetRenderW(), actualRect.Y, 1, 1, actualRect.Z);
break;
case Keys.Right:
actualRect = new SRectF(0, actualRect.Y, 1, 1, actualRect.Z);
@@ -2200,7 +2211,7 @@ namespace Vocaluxe.Menu
msg += "the file is for newer program versions! ";
msg += "Current screen version is " + Version.ToString();
CLog.LogError(msg);
_Log.LogError(msg);
}
return false;
}
@@ -2242,11 +2253,11 @@ namespace Vocaluxe.Menu
private void ReloadThemeEditMode()
{
CTheme.UnloadSkins();
CTheme.ListSkins();
CTheme.LoadSkins();
CTheme.LoadTheme();
CGraphics.ReloadTheme();
_Theme.UnloadSkins();
_Theme.ListSkins();
_Theme.LoadSkins();
_Theme.LoadTheme();
_Graphics.ReloadTheme();
OnShow();
OnShowFinish();
+309
View File
@@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Lib.Draw;
@@ -9,6 +11,8 @@ namespace Vocaluxe.Menu
{
interface IMenu
{
void Initialize(IConfig Config, ISettings Settings, ITheme Theme, IHelper Helper, ILog Log, IBackgroundMusic BackgroundMusic, IDrawing Draw, IGraphics Graphics);
void LoadTheme();
void SaveTheme();
void ReloadTextures();
@@ -38,4 +42,309 @@ namespace Vocaluxe.Menu
void ProcessMouseClick(int x, int y);
void ProcessMouseMove(int x, int y);
}
interface IConfig
{
void SetBackgroundMusicVolume(int NewVolume);
int GetBackgroundMusicVolume();
}
interface ISettings
{
int GetRenderW();
int GetRenderH();
bool IsTabNavigation();
float GetZFar();
float GetZNear();
EGameState GetGameState();
}
interface ITheme
{
string GetThemeScreensPath();
int GetSkinIndex();
void UnloadSkins();
void ListSkins();
void LoadSkins();
void LoadTheme();
}
interface IHelper
{
}
interface IBackgroundMusic
{
bool IsDisabled();
bool IsPlaying();
void Next();
void Previous();
void Pause();
void Play();
void ApplyVolume();
}
interface IDrawing
{
RectangleF GetTextBounds(CText text);
}
interface IGraphics
{
void ReloadTheme();
}
interface ILog
{
void LogError(string ErrorText);
}
[Flags]
public enum EModifier
{
None,
Shift,
Alt,
Ctrl
}
public enum ESender
{
Mouse,
Keyboard,
WiiMote,
Gamepad
}
public struct KeyEvent
{
public ESender Sender;
public bool ModALT;
public bool ModSHIFT;
public bool ModCTRL;
public bool KeyPressed;
public bool Handled;
public Keys Key;
public Char Unicode;
public EModifier Mod;
public KeyEvent(ESender sender, bool alt, bool shift, bool ctrl, bool pressed, char unicode, Keys key)
{
Sender = sender;
ModALT = alt;
ModSHIFT = shift;
ModCTRL = ctrl;
KeyPressed = pressed;
Unicode = unicode;
Key = key;
Handled = false;
EModifier mALT = EModifier.None;
EModifier mSHIFT = EModifier.None;
EModifier mCTRL = EModifier.None;
if (alt)
mALT = EModifier.Alt;
if (shift)
mSHIFT = EModifier.Shift;
if (ctrl)
mCTRL = EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mALT | mSHIFT | mCTRL;
}
}
public struct MouseEvent
{
public ESender Sender;
public int X;
public int Y;
public bool LB; //left button click
public bool LD; //left button double click
public bool RB; //right button click
public bool MB; //middle button click
public bool LBH; //left button hold (when moving)
public bool RBH; //right button hold (when moving)
public bool MBH; //middle button hold (when moving)
public bool ModALT;
public bool ModSHIFT;
public bool ModCTRL;
public EModifier Mod;
public int Wheel;
public MouseEvent(ESender sender, bool alt, bool shift, bool ctrl, int x, int y, bool lb, bool ld, bool rb, int wheel, bool lbh, bool rbh, bool mb, bool mbh)
{
Sender = sender;
X = x;
Y = y;
LB = lb;
LD = ld;
RB = rb;
MB = mb;
LBH = lbh;
RBH = rbh;
MBH = mbh;
ModALT = alt;
ModSHIFT = shift;
ModCTRL = ctrl;
EModifier mALT = EModifier.None;
EModifier mSHIFT = EModifier.None;
EModifier mCTRL = EModifier.None;
if (alt)
mALT = EModifier.Alt;
if (shift)
mSHIFT = EModifier.Shift;
if (ctrl)
mCTRL = EModifier.Ctrl;
if (!alt && !shift && !ctrl)
Mod = EModifier.None;
else
Mod = mALT | mSHIFT | mCTRL;
Wheel = wheel;
}
}
public enum EGameState
{
Start,
Normal,
EditTheme
}
enum EAspect
{
Crop,
LetterBox,
Stretch
}
#region Structs
public struct SColorF
{
public float R;
public float G;
public float B;
public float A;
public SColorF(float r, float g, float b, float a)
{
R = r;
G = g;
B = b;
A = a;
}
public SColorF(SColorF Color)
{
R = Color.R;
G = Color.G;
B = Color.B;
A = Color.A;
}
}
public struct SRectF
{
public float X;
public float Y;
public float W;
public float H;
public float Z;
public float Rotation; //0..360°
public SRectF(float x, float y, float w, float h, float z)
{
X = x;
Y = y;
W = w;
H = h;
Z = z;
Rotation = 0f;
}
public SRectF(SRectF rect)
{
X = rect.X;
Y = rect.Y;
W = rect.W;
H = rect.H;
Z = rect.Z;
Rotation = 0f;
}
}
public struct SPoint3f
{
public float X;
public float Y;
public float Z;
}
public struct SPoint3
{
public int X;
public int Y;
public int Z;
}
public struct STexture
{
public int index;
public int PBO;
public int ID;
public string TexturePath;
public float width;
public float height;
public SRectF rect;
public float w2; //power of 2 width
public float h2; //power of 2 height
public float width_ratio;
public float height_ratio;
public SColorF color;
public STexture(int Index)
{
index = Index;
PBO = 0;
ID = -1;
TexturePath = String.Empty;
width = 1f;
height = 1f;
rect = new SRectF(0f, 0f, 1f, 1f, 0f);
w2 = 2f;
h2 = 2f;
width_ratio = 0.5f;
height_ratio = 0.5f;
color = new SColorF(1f, 1f, 1f, 1f);
}
}
#endregion Structs
}
@@ -76,7 +76,6 @@ namespace Vocaluxe.Screens
public CPopupScreenPlayerControl()
{
Init();
}
protected override void Init()
@@ -24,7 +24,6 @@ namespace Vocaluxe.Screens
public CPopupScreenVolumeControl()
{
Init();
}
protected override void Init()
-1
View File
@@ -59,7 +59,6 @@ namespace Vocaluxe.Screens
public CScreenCredits()
{
Init();
}
protected override void Init()
-1
View File
@@ -31,7 +31,6 @@ namespace Vocaluxe.Screens
public CScreenHighscore()
{
Init();
}
protected override void Init()
-1
View File
@@ -36,7 +36,6 @@ namespace Vocaluxe.Screens
public CScreenLoad()
{
Init();
}
protected override void Init()
-1
View File
@@ -28,7 +28,6 @@ namespace Vocaluxe.Screens
public CScreenMain()
{
Init();
}
protected override void Init()
-1
View File
@@ -43,7 +43,6 @@ namespace Vocaluxe.Screens
public CScreenNames()
{
Init();
}
protected override void Init()
-1
View File
@@ -23,7 +23,6 @@ namespace Vocaluxe.Screens
public CScreenOptions()
{
Init();
}
protected override void Init()
-1
View File
@@ -32,7 +32,6 @@ namespace Vocaluxe.Screens
public CScreenOptionsGame()
{
Init();
}
protected override void Init()
-1
View File
@@ -20,7 +20,6 @@ namespace Vocaluxe.Screens
public CScreenOptionsLyrics()
{
Init();
}
protected override void Init()
-1
View File
@@ -56,7 +56,6 @@ namespace Vocaluxe.Screens
public CScreenOptionsRecord()
{
Init();
}
protected override void Init()
-1
View File
@@ -27,7 +27,6 @@ namespace Vocaluxe.Screens
public CScreenOptionsSound()
{
Init();
}
protected override void Init()
-1
View File
@@ -33,7 +33,6 @@ namespace Vocaluxe.Screens
public CScreenOptionsTheme()
{
Init();
}
protected override void Init()
+1 -2
View File
@@ -27,13 +27,12 @@ namespace Vocaluxe.Screens
private const string ButtonExit = "ButtonExit";
private SWebcamConfig _Config;
Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1);
STexture _WebcamTexture = new STexture(-1);
private int _DeviceNr;
private int _CapabilityNr;
public CScreenOptionsVideo()
{
Init();
}
protected override void Init()
-1
View File
@@ -16,7 +16,6 @@ namespace Vocaluxe.Screens
public CScreenParty()
{
Init();
}
protected override void Init()
-1
View File
@@ -14,7 +14,6 @@ namespace Vocaluxe.Screens
public CScreenPartyDummy()
{
Init();
}
protected override void Init()
+1 -2
View File
@@ -41,12 +41,11 @@ namespace Vocaluxe.Screens
private EEditMode _EditMode;
private Lib.Draw.STexture _WebcamTexture = new Lib.Draw.STexture(-1);
private STexture _WebcamTexture = new STexture(-1);
private Bitmap _Snapshot = null;
public CScreenProfiles()
{
Init();
}
protected override void Init()
+1 -2
View File
@@ -33,7 +33,6 @@ namespace Vocaluxe.Screens
public CScreenScore()
{
Init();
}
protected override void Init()
@@ -366,7 +365,7 @@ namespace Vocaluxe.Screens
Statics[htStatics(StaticPointsBarBG[player, numplayer])].Visible = (numplayer + 1 == CGame.NumPlayer);
Statics[htStatics(StaticAvatar[player, numplayer])].Visible = (numplayer + 1 == CGame.NumPlayer);
Statics[htStatics(StaticAvatar[player, numplayer])].Texture = new Lib.Draw.STexture(-1);
Statics[htStatics(StaticAvatar[player, numplayer])].Texture = new STexture(-1);
}
}
}
-1
View File
@@ -97,7 +97,6 @@ namespace Vocaluxe.Screens
public CScreenSing()
{
Init();
}
protected override void Init()
-2
View File
@@ -68,8 +68,6 @@ namespace Vocaluxe.Screens
public CScreenSong()
{
Init();
_AvailableGameModes = new List<GameModes.EGameMode>();
}
-1
View File
@@ -19,7 +19,6 @@ namespace Vocaluxe.Screens
public CScreenTest()
{
Init();
}
protected override void Init()
+7 -2
View File
@@ -6,8 +6,13 @@ using Vocaluxe.Menu;
namespace Vocaluxe.Screens.PartyScreens
{
abstract class CMenuParty : CMenu
abstract class CMenuParty
{
public CMenuParty()
{
}
/*
public sealed override void LoadTheme()
{
}
@@ -23,7 +28,7 @@ namespace Vocaluxe.Screens.PartyScreens
public override void UnloadTextures()
{
}
*/
}
}
+2
View File
@@ -180,6 +180,7 @@
<Compile Include="Base\CInput.cs" />
<Compile Include="Base\CLanguage.cs" />
<Compile Include="Base\CLog.cs" />
<Compile Include="Base\CMain.cs" />
<Compile Include="Base\CParty.cs" />
<Compile Include="Base\CPlaylists.cs" />
<Compile Include="Base\CProfiles.cs" />
@@ -230,6 +231,7 @@
<Compile Include="Menu\CButton.cs" />
<Compile Include="Menu\CEqualizer.cs" />
<Compile Include="Base\CGraphics.cs" />
<Compile Include="Menu\CHelper.cs" />
<Compile Include="Menu\CNameSelection.cs" />
<Compile Include="Menu\CLyric.cs" />
<Compile Include="Menu\CMenu.cs" />