Duplicate Code in CMenu. CFont, CLanguage removed

This commit is contained in:
Flamefire committed 2013-03-18 18:17:50 +01:00
1 parent 1eef829479
commit c3b447ccf6
31 files changed
+299 -752

No files matched your search

+28 -26
View File
@@ -1,29 +1,31 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<root> <root>
<Font1> <Fonts>
<Name>Normal</Name> <Font1>
<Outline>0,00</Outline> <Name>Normal</Name>
<OutlineColorR>0,00</OutlineColorR> <Outline>0,00</Outline>
<OutlineColorG>0,00</OutlineColorG> <OutlineColorR>0,00</OutlineColorR>
<OutlineColorB>0,00</OutlineColorB> <OutlineColorG>0,00</OutlineColorG>
<OutlineColorA>1,00</OutlineColorA> <OutlineColorB>0,00</OutlineColorB>
<Folder>FreeSans</Folder> <OutlineColorA>1,00</OutlineColorA>
<FileNormal>FreeSans.ttf</FileNormal> <Folder>FreeSans</Folder>
<FileBold>FreeSansBold.ttf</FileBold> <FileNormal>FreeSans.ttf</FileNormal>
<FileItalic>FreeSansOblique.ttf</FileItalic> <FileBold>FreeSansBold.ttf</FileBold>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic> <FileItalic>FreeSansOblique.ttf</FileItalic>
</Font1> <FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
<Font2> </Font1>
<Name>Outline</Name> <Font2>
<Outline>0,10</Outline> <Name>Outline</Name>
<OutlineColorR>0,00</OutlineColorR> <Outline>0,10</Outline>
<OutlineColorG>0,00</OutlineColorG> <OutlineColorR>0,00</OutlineColorR>
<OutlineColorB>0,00</OutlineColorB> <OutlineColorG>0,00</OutlineColorG>
<OutlineColorA>1,00</OutlineColorA> <OutlineColorB>0,00</OutlineColorB>
<Folder>FreeSans</Folder> <OutlineColorA>1,00</OutlineColorA>
<FileNormal>FreeSans.ttf</FileNormal> <Folder>FreeSans</Folder>
<FileBold>FreeSansBold.ttf</FileBold> <FileNormal>FreeSans.ttf</FileNormal>
<FileItalic>FreeSansOblique.ttf</FileItalic> <FileBold>FreeSansBold.ttf</FileBold>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic> <FileItalic>FreeSansOblique.ttf</FileItalic>
</Font2> <FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font2>
</Fonts>
</root> </root>
@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Font1>
<Name>Normal</Name>
<Outline>0,00</Outline>
<OutlineColorR>0,00</OutlineColorR>
<OutlineColorG>0,00</OutlineColorG>
<OutlineColorB>0,00</OutlineColorB>
<OutlineColorA>1,00</OutlineColorA>
<Folder>FreeSans</Folder>
<FileNormal>FreeSans.ttf</FileNormal>
<FileBold>FreeSansBold.ttf</FileBold>
<FileItalic>FreeSansOblique.ttf</FileItalic>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font1>
<Font2>
<Name>Outline</Name>
<Outline>0,10</Outline>
<OutlineColorR>0,00</OutlineColorR>
<OutlineColorG>0,00</OutlineColorG>
<OutlineColorB>0,00</OutlineColorB>
<OutlineColorA>1,00</OutlineColorA>
<Folder>FreeSans</Folder>
<FileNormal>FreeSans.ttf</FileNormal>
<FileBold>FreeSansBold.ttf</FileBold>
<FileItalic>FreeSansOblique.ttf</FileItalic>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font2>
</root>
@@ -1,40 +0,0 @@
Congratulations, you have successfully downloaded font file!
This font is provided to you by Fonts2u.com – the largest online
repository of free fonts for Windows and Mac.
How to install this font on your computer?
For Windows 7 / Vista users:
- Right-click the font file(s) and choose "Install".
For users of the previous Windows versions:
- Copy the included file(s) into a default Windows font folder
(usually C:\WINDOWS\FONTS or C:\WINNT\FONTS)
For Mac users:
Mac OS X 10.3 or above (including the FontBook)
- Double-click the font file and hit "Install font" button at
the bottom of the preview.
Mac OS X
- Either copy the font file(s) to /Library/Fonts (for all users),
or to /Users/Your_username/Library/Fonts (for you only).
Mac OS 9 or earlier
- You have to convert the font file(s) you have downloaded.
Drag the font suitcases into the System folder. The system
will propose you to add them to the Fonts folder.
For Linux users:
- Copy the font file(s) to /USR/SHARE/FONTS
@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Font1>
<Name>Normal</Name>
<Outline>0,00</Outline>
<OutlineColorR>0,00</OutlineColorR>
<OutlineColorG>0,00</OutlineColorG>
<OutlineColorB>0,00</OutlineColorB>
<OutlineColorA>1,00</OutlineColorA>
<Folder>FreeSans</Folder>
<FileNormal>FreeSans.ttf</FileNormal>
<FileBold>FreeSansBold.ttf</FileBold>
<FileItalic>FreeSansOblique.ttf</FileItalic>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font1>
<Font2>
<Name>Outline</Name>
<Outline>0,10</Outline>
<OutlineColorR>0,00</OutlineColorR>
<OutlineColorG>0,00</OutlineColorG>
<OutlineColorB>0,00</OutlineColorB>
<OutlineColorA>1,00</OutlineColorA>
<Folder>FreeSans</Folder>
<FileNormal>FreeSans.ttf</FileNormal>
<FileBold>FreeSansBold.ttf</FileBold>
<FileItalic>FreeSansOblique.ttf</FileItalic>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font2>
</root>
@@ -1,40 +0,0 @@
Congratulations, you have successfully downloaded font file!
This font is provided to you by Fonts2u.com – the largest online
repository of free fonts for Windows and Mac.
How to install this font on your computer?
For Windows 7 / Vista users:
- Right-click the font file(s) and choose "Install".
For users of the previous Windows versions:
- Copy the included file(s) into a default Windows font folder
(usually C:\WINDOWS\FONTS or C:\WINNT\FONTS)
For Mac users:
Mac OS X 10.3 or above (including the FontBook)
- Double-click the font file and hit "Install font" button at
the bottom of the preview.
Mac OS X
- Either copy the font file(s) to /Library/Fonts (for all users),
or to /Users/Your_username/Library/Fonts (for you only).
Mac OS 9 or earlier
- You have to convert the font file(s) you have downloaded.
Drag the font suitcases into the System folder. The system
will propose you to add them to the Fonts folder.
For Linux users:
- Copy the font file(s) to /USR/SHARE/FONTS
@@ -1,29 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<root>
<Font1>
<Name>Normal</Name>
<Outline>0,00</Outline>
<OutlineColorR>0,00</OutlineColorR>
<OutlineColorG>0,00</OutlineColorG>
<OutlineColorB>0,00</OutlineColorB>
<OutlineColorA>1,00</OutlineColorA>
<Folder>FreeSans</Folder>
<FileNormal>FreeSans.ttf</FileNormal>
<FileBold>FreeSansBold.ttf</FileBold>
<FileItalic>FreeSansOblique.ttf</FileItalic>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font1>
<Font2>
<Name>Outline</Name>
<Outline>0,10</Outline>
<OutlineColorR>0,00</OutlineColorR>
<OutlineColorG>0,00</OutlineColorG>
<OutlineColorB>0,00</OutlineColorB>
<OutlineColorA>1,00</OutlineColorA>
<Folder>FreeSans</Folder>
<FileNormal>FreeSans.ttf</FileNormal>
<FileBold>FreeSansBold.ttf</FileBold>
<FileItalic>FreeSansOblique.ttf</FileItalic>
<FileBoldItalic>FreeSansBoldOblique.ttf</FileBoldItalic>
</Font2>
</root>
@@ -1,40 +0,0 @@
Congratulations, you have successfully downloaded font file!
This font is provided to you by Fonts2u.com – the largest online
repository of free fonts for Windows and Mac.
How to install this font on your computer?
For Windows 7 / Vista users:
- Right-click the font file(s) and choose "Install".
For users of the previous Windows versions:
- Copy the included file(s) into a default Windows font folder
(usually C:\WINDOWS\FONTS or C:\WINNT\FONTS)
For Mac users:
Mac OS X 10.3 or above (including the FontBook)
- Double-click the font file and hit "Install font" button at
the bottom of the preview.
Mac OS X
- Either copy the font file(s) to /Library/Fonts (for all users),
or to /Users/Your_username/Library/Fonts (for you only).
Mac OS 9 or earlier
- You have to convert the font file(s) you have downloaded.
Drag the font suitcases into the System folder. The system
will propose you to add them to the Fonts folder.
For Linux users:
- Copy the font file(s) to /USR/SHARE/FONTS
+1 -13
View File
@@ -211,25 +211,13 @@ namespace Vocaluxe.Base
if (NumPlayer < 1 || NumPlayer > CSettings.MaxNumPlayer) if (NumPlayer < 1 || NumPlayer > CSettings.MaxNumPlayer)
NumPlayer = 2; NumPlayer = 2;
List<string> _Languages = new List<string>(); bool _LangExists = CLanguage.SetLanguage(Language);
_Languages = CLanguage.GetLanguages();
bool _LangExists = false;
for (i = 0; i < _Languages.Count; i++)
{
if (_Languages[i] == Language)
{
_LangExists = true;
}
}
//TODO: What should we do, if English not exists? //TODO: What should we do, if English not exists?
if(_LangExists == false){ if(_LangExists == false){
Language = "English"; Language = "English";
} }
CLanguage.SetLanguage(Language);
//Read players from config //Read players from config
for (i = 1; i <= CSettings.MaxNumPlayer; i++) for (i = 1; i <= CSettings.MaxNumPlayer; i++)
+92 -304
View File
@@ -39,22 +39,16 @@ namespace Vocaluxe.Base
Font fo; Font fo;
Size sizeB; Size sizeB;
SizeF size; SizeF size;
System.Drawing.Graphics g; using(Graphics g=Graphics.FromHwnd(IntPtr.Zero)){
using (Bitmap bmp = new Bitmap(10, 10))
{
g = System.Drawing.Graphics.FromImage(bmp);
fo = CFonts.GetFont(); fo = CFonts.GetFont();
sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags); sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
size = g.MeasureString(chr.ToString(), fo); size = g.MeasureString(chr.ToString(), fo);
g.Dispose();
} }
using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height)) using (Bitmap bmp = new Bitmap((int)(sizeB.Width * 2f), sizeB.Height))
{ {
g = System.Drawing.Graphics.FromImage(bmp); Graphics g = System.Drawing.Graphics.FromImage(bmp);
g.Clear(System.Drawing.Color.Transparent); g.Clear(System.Drawing.Color.Transparent);
g.SmoothingMode = SmoothingMode.AntiAlias; g.SmoothingMode = SmoothingMode.AntiAlias;
@@ -104,9 +98,8 @@ namespace Vocaluxe.Base
//bmp.Save("test.png", ImageFormat.Png); //bmp.Save("test.png", ImageFormat.Png);
Chr = chr; Chr = chr;
width = (int)((1f + outline / 2f) * sizeB.Width * Texture.width / factor / bmp.Width); width = (int)((1f + outline / 2f) * sizeB.Width * Texture.width / factor / bmp.Width);
g.Dispose();
} }
g.Dispose();
fo.Dispose(); fo.Dispose();
} }
@@ -125,29 +118,20 @@ namespace Vocaluxe.Base
CFonts.Style = EStyle.Normal; CFonts.Style = EStyle.Normal;
CFonts.Height = SIZEh; CFonts.Height = SIZEh;
float h_style, h_normal; float h_style, h_normal;
using (Bitmap bmp = new Bitmap(10, 10)) using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
{ {
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp)) Font fo = CFonts.GetFont();
{ Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
//SizeF size = g.MeasureString(chr.ToString(), fo);
Font fo = CFonts.GetFont(); h_normal = sizeB.Height;
Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
//SizeF size = g.MeasureString(chr.ToString(), fo);
h_normal = sizeB.Height;
}
CFonts.Style = style;
} }
using (Bitmap bmp = new Bitmap(10, 10)) CFonts.Style = style;
using (Graphics g = Graphics.FromHwnd(IntPtr.Zero))
{ {
using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(bmp)) Font fo = CFonts.GetFont();
{ Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
//size = g.MeasureString(chr.ToString(), fo);
Font fo = CFonts.GetFont(); h_style = sizeB.Height;
Size sizeB = TextRenderer.MeasureText(g, chr.ToString(), fo, new Size(int.MaxValue, int.MaxValue), flags);
//size = g.MeasureString(chr.ToString(), fo);
h_style = sizeB.Height;
}
} }
return h_normal / h_style; return h_normal / h_style;
} }
@@ -399,22 +383,25 @@ namespace Vocaluxe.Base
} }
public static Font GetFont() public static Font GetFont()
{
return _GetCurrentFont().GetFont();
}
private static CFont _GetCurrentFont()
{ {
switch (Style) switch (Style)
{ {
case EStyle.Normal: case EStyle.Normal:
return _Fonts[_CurrentFont].Normal.GetFont(); return _Fonts[_CurrentFont].Normal;
case EStyle.Italic: case EStyle.Italic:
return _Fonts[_CurrentFont].Italic.GetFont(); return _Fonts[_CurrentFont].Italic;
case EStyle.Bold: case EStyle.Bold:
return _Fonts[_CurrentFont].Bold.GetFont(); return _Fonts[_CurrentFont].Bold;
case EStyle.BoldItalic: case EStyle.BoldItalic:
return _Fonts[_CurrentFont].BoldItalic.GetFont(); return _Fonts[_CurrentFont].BoldItalic;
default:
break;
} }
// should never happen... //Just in case...
return null; return _Fonts[_CurrentFont].Normal;
} }
#region DrawText #region DrawText
@@ -437,31 +424,13 @@ namespace Vocaluxe.Base
return; return;
Height = h; Height = h;
CFont Font = _GetCurrentFont();
float dx = x; float dx = x;
foreach (char chr in Text) foreach (char chr in Text)
{ {
switch (Style) Font.DrawGlyph(chr, dx, y, Height, z, color);
{ dx += Font.GetWidth(chr);
case EStyle.Normal:
_Fonts[_CurrentFont].Normal.DrawGlyph(chr, dx, y, Height, z, color);
dx += _Fonts[_CurrentFont].Normal.GetWidth(chr);
break;
case EStyle.Italic:
_Fonts[_CurrentFont].Italic.DrawGlyph(chr, dx, y, Height, z, color);
dx += _Fonts[_CurrentFont].Italic.GetWidth(chr);
break;
case EStyle.Bold:
_Fonts[_CurrentFont].Bold.DrawGlyph(chr, dx, y, Height, z, color);
dx += _Fonts[_CurrentFont].Bold.GetWidth(chr);
break;
case EStyle.BoldItalic:
_Fonts[_CurrentFont].BoldItalic.DrawGlyph(chr, dx, y, Height, z, color);
dx += _Fonts[_CurrentFont].BoldItalic.GetWidth(chr);
break;
default:
break;
}
} }
} }
@@ -474,31 +443,13 @@ namespace Vocaluxe.Base
return; return;
Height = h; Height = h;
CFont Font = _GetCurrentFont();
float dx = x; float dx = x;
foreach (char chr in Text) foreach (char chr in Text)
{ {
switch (Style) Font.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
{ dx += Font.GetWidth(chr);
case EStyle.Normal:
_Fonts[_CurrentFont].Normal.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
dx += _Fonts[_CurrentFont].Normal.GetWidth(chr);
break;
case EStyle.Italic:
_Fonts[_CurrentFont].Italic.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
dx += _Fonts[_CurrentFont].Italic.GetWidth(chr);
break;
case EStyle.Bold:
_Fonts[_CurrentFont].Bold.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
dx += _Fonts[_CurrentFont].Bold.GetWidth(chr);
break;
case EStyle.BoldItalic:
_Fonts[_CurrentFont].BoldItalic.DrawGlyphReflection(chr, dx, y, Height, z, color, rspace, rheight);
dx += _Fonts[_CurrentFont].BoldItalic.GetWidth(chr);
break;
default:
break;
}
} }
} }
@@ -520,56 +471,23 @@ namespace Vocaluxe.Base
float x1 = x + w * begin; float x1 = x + w * begin;
float x2 = x + w * end; float x2 = x + w * end;
CFont Font = _GetCurrentFont();
foreach (char chr in Text) foreach (char chr in Text)
{ {
float w2 = 0f; float w2 = Font.GetWidth(chr);
switch (Style)
{
case EStyle.Normal:
w2 = _Fonts[_CurrentFont].Normal.GetWidth(chr);
break;
case EStyle.Italic:
w2 = _Fonts[_CurrentFont].Italic.GetWidth(chr);
break;
case EStyle.Bold:
w2 = _Fonts[_CurrentFont].Bold.GetWidth(chr);
break;
case EStyle.BoldItalic:
w2 = _Fonts[_CurrentFont].BoldItalic.GetWidth(chr);
break;
default:
break;
}
float b = (x1 - dx) / w2; float b = (x1 - dx) / w2;
if (b < 0f)
b = 0f;
if (b < 1f) if (b < 1f)
{ {
if (b < 0f)
b = 0f;
float e = (x2 - dx) / w2; float e = (x2 - dx) / w2;
if (e > 1f)
e = 1f;
if (e > 0f) if (e > 0f)
{ {
switch (Style) if (e > 1f)
{ e = 1f;
case EStyle.Normal: Font.DrawGlyph(chr, dx, y, Height, z, color, b, e);
_Fonts[_CurrentFont].Normal.DrawGlyph(chr, dx, y, Height, z, color, b, e);
break;
case EStyle.Italic:
_Fonts[_CurrentFont].Italic.DrawGlyph(chr, dx, y, Height, z, color, b, e);
break;
case EStyle.Bold:
_Fonts[_CurrentFont].Bold.DrawGlyph(chr, dx, y, Height, z, color, b, e);
break;
case EStyle.BoldItalic:
_Fonts[_CurrentFont].BoldItalic.DrawGlyph(chr, dx, y, Height, z, color, b, e);
break;
default:
break;
}
} }
} }
dx += w2; dx += w2;
@@ -641,25 +559,10 @@ namespace Vocaluxe.Base
public static float GetTextWidth(string text) public static float GetTextWidth(string text)
{ {
float dx = 0; float dx = 0;
CFont Font = _GetCurrentFont();
foreach (char chr in text) foreach (char chr in text)
{ {
switch (Style) dx += Font.GetWidth(chr);
{
case EStyle.Normal:
dx += _Fonts[_CurrentFont].Normal.GetWidth(chr);
break;
case EStyle.Italic:
dx += _Fonts[_CurrentFont].Italic.GetWidth(chr);
break;
case EStyle.Bold:
dx += _Fonts[_CurrentFont].Bold.GetWidth(chr);
break;
case EStyle.BoldItalic:
dx += _Fonts[_CurrentFont].BoldItalic.GetWidth(chr);
break;
default:
break;
}
} }
return dx; return dx;
} }
@@ -668,126 +571,39 @@ namespace Vocaluxe.Base
{ {
//return TextRenderer.MeasureText(text, GetFont()).Height; //return TextRenderer.MeasureText(text, GetFont()).Height;
float h = 0f; float h = 0f;
CFont Font = _GetCurrentFont();
foreach (char chr in text) foreach (char chr in text)
{ {
float hh = 0f; float hh = Font.GetHeight(chr);
switch (Style)
{
case EStyle.Normal:
hh = _Fonts[_CurrentFont].Normal.GetHeight(chr);
break;
case EStyle.Italic:
hh = _Fonts[_CurrentFont].Italic.GetHeight(chr);
break;
case EStyle.Bold:
hh = _Fonts[_CurrentFont].Bold.GetHeight(chr);
break;
case EStyle.BoldItalic:
hh = _Fonts[_CurrentFont].BoldItalic.GetHeight(chr);
break;
default:
break;
}
if (hh>h) if (hh>h)
h = hh; h = hh;
} }
return h; return h;
} }
/// <summary> private static void _LoadFontFiles(CXMLReader xmlReader, string FontFolder, string ThemeName="", int PartyModeId=-1){
/// Load default fonts
/// </summary>
/// <returns></returns>
private static bool LoadFontList()
{
CXMLReader xmlReader = CXMLReader.OpenFile(System.IO.Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
if (xmlReader == null)
return false;
_Fonts.Clear();
string value = string.Empty;
int i = 1;
while (xmlReader.GetValue("//root/Font" + i.ToString() + "/Folder", ref value, value))
{
string Folder = value;
xmlReader.GetValue("//root/Font" + i.ToString() + "/FileNormal", ref value, value);
value = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
CFont f = new CFont(value);
SFont sf = new SFont();
sf.Normal = f;
string name = String.Empty;
xmlReader.GetValue("//root/Font" + i.ToString() + "/Name", ref name, value);
sf.Name = name;
sf.IsThemeFont = false;
sf.ThemeName = String.Empty;
sf.PartyModeID = -1;
xmlReader.GetValue("//root/Font" + i.ToString() + "/FileItalic", ref value, value);
value = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
f = new CFont(value);
sf.Italic = f;
xmlReader.GetValue("//root/Font" + i.ToString() + "/FileBold", ref value, value);
value = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
f = new CFont(value);
sf.Bold = f;
xmlReader.GetValue("//root/Font" + i.ToString() + "/FileBoldItalic", ref value, value);
value = Path.Combine(Directory.GetCurrentDirectory(),
Path.Combine(CSettings.sFolderFonts, Path.Combine(Folder, value)));
f = new CFont(value);
sf.BoldItalic = f;
sf.Outline = 0f;
xmlReader.TryGetFloatValue("//root/Font" + i.ToString() + "/Outline", ref sf.Outline);
sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
xmlReader.TryGetFloatValue("//root/Font" + i.ToString() + "/OutlineColorR", ref sf.OutlineColor.R);
xmlReader.TryGetFloatValue("//root/Font" + i.ToString() + "/OutlineColorG", ref sf.OutlineColor.G);
xmlReader.TryGetFloatValue("//root/Font" + i.ToString() + "/OutlineColorB", ref sf.OutlineColor.B);
xmlReader.TryGetFloatValue("//root/Font" + i.ToString() + "/OutlineColorA", ref sf.OutlineColor.A);
_Fonts.Add(sf);
i++;
}
return true;
}
/// <summary>
/// Loads theme fonts from skin file
/// </summary>
public static void LoadThemeFonts(string ThemeName, string FontFolder, CXMLReader xmlReader)
{
string value = string.Empty; string value = string.Empty;
int i = 1; int i = 1;
while (xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Folder", ref value, value)) while (xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Folder", ref value, value))
{ {
SFont sf = new SFont(); SFont sf = new SFont();
sf.Folder = value; sf.Folder = value;
sf.IsThemeFont = ThemeName.Length>0;
sf.IsThemeFont = true;
sf.ThemeName = ThemeName; sf.ThemeName = ThemeName;
sf.PartyModeID = -1; sf.PartyModeID = PartyModeId;
bool ok = true; bool ok = true;
string name = String.Empty;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Name", ref name, value);
sf.Name = name;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileNormal", ref value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileNormal", ref value, value);
sf.FileNormal = value; sf.FileNormal = value;
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
CFont f = new CFont(value); CFont f = new CFont(value);
sf.Normal = f; sf.Normal = f;
string name = String.Empty;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Name", ref name, value);
sf.Name = name;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileItalic", ref value, value); ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileItalic", ref value, value);
sf.FileItalic = value; sf.FileItalic = value;
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value)); value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
@@ -819,11 +635,52 @@ namespace Vocaluxe.Base
_Fonts.Add(sf); _Fonts.Add(sf);
else else
{ {
CLog.LogError("Error loading theme fonts for theme \"" + ThemeName + "\": Error in Font" + i.ToString()); string fontTypes;
if (PartyModeId >= 0)
fontTypes = "theme fonts for party mode";
else if (ThemeName.Length > 0)
fontTypes = "theme fonts for theme \"" + ThemeName + "\"";
else
fontTypes = "basic fonts";
CLog.LogError("Error loading "+fontTypes+": Error in Font" + i.ToString());
} }
i++; i++;
} }
}
/// <summary>
/// Load default fonts
/// </summary>
/// <returns></returns>
private static bool LoadFontList()
{
CXMLReader xmlReader = CXMLReader.OpenFile(System.IO.Path.Combine(CSettings.sFolderFonts, CSettings.sFileFonts));
if (xmlReader == null)
return false;
_Fonts.Clear();
_LoadFontFiles(xmlReader, Path.Combine(Directory.GetCurrentDirectory(), CSettings.sFolderFonts));
return true;
}
/// <summary>
/// Loads theme fonts from skin file
/// </summary>
public static void LoadThemeFonts(string ThemeName, string FontFolder, CXMLReader xmlReader)
{
_LoadFontFiles(xmlReader, FontFolder, ThemeName);
CLog.StartBenchmark(1, "BuildGlyphs");
BuildGlyphs();
CLog.StopBenchmark(1, "BuildGlyphs");
}
/// <summary>
/// Loads party mode fonts from skin file
/// </summary>
public static void LoadPartyModeFonts(int PartyModeID, string FontFolder, CXMLReader xmlReader)
{
_LoadFontFiles(xmlReader, FontFolder, "", PartyModeID);
CLog.StartBenchmark(1, "BuildGlyphs"); CLog.StartBenchmark(1, "BuildGlyphs");
BuildGlyphs(); BuildGlyphs();
CLog.StopBenchmark(1, "BuildGlyphs"); CLog.StopBenchmark(1, "BuildGlyphs");
@@ -895,75 +752,6 @@ namespace Vocaluxe.Base
} }
} }
/// <summary>
/// Loads party mode fonts from skin file
/// </summary>
public static void LoadPartyModeFonts(int PartyModeID, string FontFolder, CXMLReader xmlReader)
{
string value = string.Empty;
int i = 1;
while (xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Folder", ref value, value))
{
SFont sf = new SFont();
sf.Folder = value;
sf.IsThemeFont = false;
sf.ThemeName = String.Empty;
sf.PartyModeID = PartyModeID;
bool ok = true;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileNormal", ref value, value);
sf.FileNormal = value;
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
CFont f = new CFont(value);
sf.Normal = f;
string name = String.Empty;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/Name", ref name, value);
sf.Name = name;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileItalic", ref value, value);
sf.FileItalic = value;
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value);
sf.Italic = f;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileBold", ref value, value);
sf.FileBold = value;
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value);
sf.Bold = f;
ok &= xmlReader.GetValue("//root/Fonts/Font" + i.ToString() + "/FileBoldItalic", ref value, value);
sf.FileBoldItalic = value;
value = Path.Combine(FontFolder, Path.Combine(sf.Folder, value));
f = new CFont(value);
sf.BoldItalic = f;
sf.Outline = 0f;
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/Outline", ref sf.Outline);
sf.OutlineColor = new SColorF(0f, 0f, 0f, 1f);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorR", ref sf.OutlineColor.R);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorG", ref sf.OutlineColor.G);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorB", ref sf.OutlineColor.B);
ok &= xmlReader.TryGetFloatValue("//root/Fonts/Font" + i.ToString() + "/OutlineColorA", ref sf.OutlineColor.A);
if (ok)
_Fonts.Add(sf);
else
{
CLog.LogError("Error loading theme fonts for party mode from Folder \"" + FontFolder + "\": Error in Font" + i.ToString());
}
i++;
}
CLog.StartBenchmark(1, "BuildGlyphs");
BuildGlyphs();
CLog.StopBenchmark(1, "BuildGlyphs");
}
private static int GetFontIndex(string ThemeName, string FontName) private static int GetFontIndex(string ThemeName, string FontName)
{ {
if (ThemeName.Length == 0 || FontName.Length == 0) if (ThemeName.Length == 0 || FontName.Length == 0)
+63 -141
View File
@@ -14,14 +14,14 @@ namespace Vocaluxe.Base
public string Name; public string Name;
public string LanguageFilePath; public string LanguageFilePath;
public Hashtable Texts; public Dictionary<string, string> Texts;
public List<SPartyLanguage> PartyModeTexts; public List<SPartyLanguage> PartyModeTexts;
} }
struct SPartyLanguage struct SPartyLanguage
{ {
public int PartyModeID; public int PartyModeID;
public Hashtable Texts; public Dictionary<string, string> Texts;
} }
static class CLanguage static class CLanguage
@@ -31,7 +31,7 @@ namespace Vocaluxe.Base
private static int _CurrentLanguage = 0; private static int _CurrentLanguage = 0;
private static int _FallbackLanguage = 0; private static int _FallbackLanguage = 0;
public static int Language public static int LanguageId
{ {
get { return _CurrentLanguage; } get { return _CurrentLanguage; }
set set
@@ -41,13 +41,18 @@ namespace Vocaluxe.Base
} }
} }
public static List<string> GetLanguages() public static string GetLanguageName(int lang)
{ {
List<string> Languages = new List<string>(); return _Languages[lang].Name;
}
public static string[] GetLanguageNames()
{
string[] Languages = new string[_Languages.Count];
for (int i = 0; i < _Languages.Count; i++) for (int i = 0; i < _Languages.Count; i++)
{ {
Languages.Add(_Languages[i].Name); Languages[i]=_Languages[i].Name;
} }
return Languages; return Languages;
@@ -100,128 +105,54 @@ namespace Vocaluxe.Base
if (KeyWord == null) if (KeyWord == null)
return "Error"; return "Error";
if (KeyWord.Length < 3) if (KeyWord.Length < 3 || KeyWord.Substring(0, 3) != "TR_")
return KeyWord; return KeyWord;
string tag = KeyWord.Substring(0, 3); string result;
if (tag != "TR_")
return KeyWord;
string result = null;
int PartyModeNr = GetPartyModeNr(PartyModeID, _CurrentLanguage);
if (PartyModeID != -1) if (PartyModeID != -1)
{ {
if (PartyModeNr != -1) int PartyModeNr = GetPartyModeNr(PartyModeID, _CurrentLanguage);
{ if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.TryGetValue(KeyWord, out result))
try return result;
{
result = (string)_Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts[KeyWord];
}
catch { }
}
if (result == null && (PartyModeNr = GetPartyModeNr(PartyModeID, _FallbackLanguage)) != -1) PartyModeNr = GetPartyModeNr(PartyModeID, _FallbackLanguage);
{ if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.TryGetValue(KeyWord, out result))
try return result;
{
result = (string)_Languages[_FallbackLanguage].PartyModeTexts[PartyModeNr].Texts[KeyWord];
}
catch { }
}
} }
if (_Languages[_CurrentLanguage].Texts.TryGetValue(KeyWord, out result))
return result;
if (_Languages[_FallbackLanguage].Texts.TryGetValue(KeyWord, out result))
return result;
if (result == null) return KeyWord;
{
try
{
result = (string)_Languages[_CurrentLanguage].Texts[KeyWord];
}
catch { }
}
if (result == null)
{
// keyword not found, try fallback-language
try
{
result = (string)_Languages[_FallbackLanguage].Texts[KeyWord];
}
catch { }
if (result == null)
return KeyWord;
}
return result;
} }
public static bool TranslationExists(string KeyWord) public static bool TranslationExists(string KeyWord, int PartyModeID = -1)
{
return TranslationExists(KeyWord, -1);
}
public static bool TranslationExists(string KeyWord, int PartyModeID)
{ {
if (KeyWord == null) if (KeyWord == null)
return false; return false;
if (KeyWord.Length < 3) if (KeyWord.Length < 3 || KeyWord.Substring(0, 3) != "TR_")
return false; return false;
string tag = KeyWord.Substring(0, 3);
if (tag != "TR_")
return false;
string result = String.Empty;
int PartyModeNr = GetPartyModeNr(PartyModeID, _CurrentLanguage);
if (PartyModeID != -1) if (PartyModeID != -1)
{ {
if (PartyModeNr != -1) int PartyModeNr = GetPartyModeNr(PartyModeID, _CurrentLanguage);
{ if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.ContainsKey(KeyWord))
try return true;
{
result = (string)_Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts[KeyWord];
}
catch { }
}
if (result == null && (PartyModeNr = GetPartyModeNr(PartyModeID, _FallbackLanguage)) != -1) PartyModeNr = GetPartyModeNr(PartyModeID, _FallbackLanguage);
{ if (PartyModeNr != -1 && _Languages[_CurrentLanguage].PartyModeTexts[PartyModeNr].Texts.ContainsKey(KeyWord))
try return true;
{
result = (string)_Languages[_FallbackLanguage].PartyModeTexts[PartyModeNr].Texts[KeyWord];
}
catch { }
}
} }
if (_Languages[_CurrentLanguage].Texts.ContainsKey(KeyWord))
return true;
if (_Languages[_FallbackLanguage].Texts.ContainsKey(KeyWord))
return true;
if (result == null) return false;
{
try
{
result = (string)_Languages[_CurrentLanguage].Texts[KeyWord];
}
catch { }
}
if (result == null)
{
// keyword not found, try fallback-language
try
{
result = (string)_Languages[_FallbackLanguage].Texts[KeyWord];
}
catch { }
if (result == null)
return false;
}
return true;
} }
public static bool LoadPartyLanguageFiles(int PartyModeID, string Path) public static bool LoadPartyLanguageFiles(int PartyModeID, string Path)
@@ -237,6 +168,29 @@ namespace Vocaluxe.Base
return true; return true;
} }
private static bool _LoadLanguageEntries(CXMLReader xmlReader, ref Dictionary<string, string> Texts)
{
Texts = new Dictionary<string, string>();
List<string> names = xmlReader.GetAttributes("resources", "name");
string value = string.Empty;
foreach(string name in names)
{
if (xmlReader.GetValue("//resources/string[@name='" + name + "']", ref value, ""))
{
try
{
Texts.Add(name, value);
}
catch (Exception e)
{
CLog.LogError("Error reading language file " + xmlReader.FileName + ": " + e.Message);
return false;
}
}
}
return true;
}
private static bool LoadPartyLanguageFile(int PartyModeID, string file) private static bool LoadPartyLanguageFile(int PartyModeID, string file)
{ {
CXMLReader xmlReader = CXMLReader.OpenFile(file); CXMLReader xmlReader = CXMLReader.OpenFile(file);
@@ -253,25 +207,9 @@ namespace Vocaluxe.Base
SPartyLanguage lang = new SPartyLanguage(); SPartyLanguage lang = new SPartyLanguage();
lang.PartyModeID = PartyModeID; lang.PartyModeID = PartyModeID;
lang.Texts = new Hashtable(); if (!_LoadLanguageEntries(xmlReader, ref lang.Texts))
return false;
List<string> texts = xmlReader.GetAttributes("resources", "name");
for (int i = 0; i < texts.Count; i++)
{
if (xmlReader.GetValue("//resources/string[@name='" + texts[i] + "']", ref value, value))
{
try
{
lang.Texts.Add(texts[i], value);
}
catch (Exception e)
{
CLog.LogError("Error reading Party Language File " + file + ": " + e.Message);
return false;
}
}
}
_Languages[nr].PartyModeTexts.Add(lang); _Languages[nr].PartyModeTexts.Add(lang);
return true; return true;
} }
@@ -299,25 +237,9 @@ namespace Vocaluxe.Base
if (lang.Name == CSettings.FallbackLanguage) if (lang.Name == CSettings.FallbackLanguage)
_FallbackLanguage = _Languages.Count; _FallbackLanguage = _Languages.Count;
lang.Texts = new Hashtable();
lang.PartyModeTexts = new List<SPartyLanguage>(); lang.PartyModeTexts = new List<SPartyLanguage>();
List<string> texts = xmlReader.GetAttributes("resources", "name"); _LoadLanguageEntries(xmlReader, ref lang.Texts);
for (int i = 0; i < texts.Count; i++)
{
if (xmlReader.GetValue("//resources/string[@name='" + texts[i] + "']", ref value, value))
{
try
{
lang.Texts.Add(texts[i], value);
}
catch (Exception e)
{
CLog.LogError("Error reading Language File " + FileName + ": " + e.Message);
}
}
}
_Languages.Add(lang); _Languages.Add(lang);
} }
+2 -2
View File
@@ -360,9 +360,9 @@ namespace Vocaluxe.Base
if (CompileResult.Errors.Count > 0) if (CompileResult.Errors.Count > 0)
{ {
for (int i = 0; i < CompileResult.Errors.Count; i++) foreach (CompilerError e in CompileResult.Errors)
{ {
CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + CompileResult.Errors[i].ErrorText); CLog.LogError("Error Compiling Source (" + CHelper.ListStrings(files) + "): " + e.ErrorText+" in '"+e.FileName+"' ("+e.Line+")");
} }
return null; return null;
} }
+1 -1
View File
@@ -631,7 +631,7 @@ namespace Vocaluxe.Lib.Draw
public RectangleF GetTextBounds(CText text, float Height) public RectangleF GetTextBounds(CText text, float Height)
{ {
CFonts.Height = Height; CFonts.Height = Height;
CFonts.SetFont(text.Fon); CFonts.SetFont(text.Font);
CFonts.Style = text.Style; CFonts.Style = text.Style;
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text))); return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
} }
+1 -1
View File
@@ -274,7 +274,7 @@ namespace Vocaluxe.Lib.Draw
public RectangleF GetTextBounds(CText text, float Height) public RectangleF GetTextBounds(CText text, float Height)
{ {
CFonts.Height = Height; CFonts.Height = Height;
CFonts.SetFont(text.Fon); CFonts.SetFont(text.Font);
CFonts.Style = text.Style; CFonts.Style = text.Style;
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text))); return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
} }
+1 -1
View File
@@ -534,7 +534,7 @@ namespace Vocaluxe.Lib.Draw
public RectangleF GetTextBounds(CText text, float Height) public RectangleF GetTextBounds(CText text, float Height)
{ {
CFonts.Height = Height; CFonts.Height = Height;
CFonts.SetFont(text.Fon); CFonts.SetFont(text.Font);
CFonts.Style = text.Style; CFonts.Style = text.Style;
return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text))); return new RectangleF(text.X, text.Y, CFonts.GetTextWidth(CLanguage.Translate(text.Text)), CFonts.GetTextHeight(CLanguage.Translate(text.Text)));
} }
+5 -22
View File
@@ -24,9 +24,6 @@ namespace Vocaluxe.Screens
private const string ButtonExit = "ButtonExit"; private const string ButtonExit = "ButtonExit";
private string[] _Languages;
private int _CurrentLang = -1;
public CScreenOptionsGame() public CScreenOptionsGame()
{ {
} }
@@ -39,24 +36,14 @@ namespace Vocaluxe.Screens
_ScreenVersion = ScreenVersion; _ScreenVersion = ScreenVersion;
_ThemeButtons = new string[] { ButtonExit }; _ThemeButtons = new string[] { ButtonExit };
_ThemeSelectSlides = new string[] { SelectSlideLanguage, SelectSlideDebugLevel, SelectSlideSongMenu, SelectSlideSongSorting, SelectSlideTabs, SelectSlideTimerMode }; _ThemeSelectSlides = new string[] { SelectSlideLanguage, SelectSlideDebugLevel, SelectSlideSongMenu, SelectSlideSongSorting, SelectSlideTabs, SelectSlideTimerMode };
_Languages = CLanguage.GetLanguages().ToArray();
for (int i = 0; i < _Languages.Length; i++)
{
if (_Languages[i] == CConfig.Language)
{
_CurrentLang = i;
}
}
} }
public override void LoadTheme(string XmlPath) public override void LoadTheme(string XmlPath)
{ {
base.LoadTheme(XmlPath); base.LoadTheme(XmlPath);
SelectSlides[SelectSlideLanguage].AddValues(_Languages); SelectSlides[SelectSlideLanguage].AddValues(CLanguage.GetLanguageNames());
SelectSlides[SelectSlideLanguage].Selection = _CurrentLang; SelectSlides[SelectSlideLanguage].Selection = CLanguage.LanguageId;
SelectSlides[SelectSlideDebugLevel].SetValues<EDebugLevel>((int)CConfig.DebugLevel); SelectSlides[SelectSlideDebugLevel].SetValues<EDebugLevel>((int)CConfig.DebugLevel);
SelectSlides[SelectSlideSongMenu].SetValues<ESongMenu>((int)CConfig.SongMenu); SelectSlides[SelectSlideSongMenu].SetValues<ESongMenu>((int)CConfig.SongMenu);
@@ -70,11 +57,7 @@ namespace Vocaluxe.Screens
{ {
base.HandleInput(KeyEvent); base.HandleInput(KeyEvent);
if (KeyEvent.KeyPressed) if (!KeyEvent.KeyPressed)
{
}
else
{ {
switch (KeyEvent.Key) switch (KeyEvent.Key)
{ {
@@ -143,7 +126,8 @@ namespace Vocaluxe.Screens
private void SaveConfig() private void SaveConfig()
{ {
CConfig.Language = _Languages[SelectSlides[SelectSlideLanguage].Selection]; CLanguage.LanguageId = SelectSlides[SelectSlideLanguage].Selection;
CConfig.Language = CLanguage.GetLanguageName(CLanguage.LanguageId);
CConfig.DebugLevel = (EDebugLevel)SelectSlides[SelectSlideDebugLevel].Selection; CConfig.DebugLevel = (EDebugLevel)SelectSlides[SelectSlideDebugLevel].Selection;
CConfig.SongMenu = (ESongMenu)SelectSlides[SelectSlideSongMenu].Selection; CConfig.SongMenu = (ESongMenu)SelectSlides[SelectSlideSongMenu].Selection;
CConfig.SongSorting = (ESongSorting)SelectSlides[SelectSlideSongSorting].Selection; CConfig.SongSorting = (ESongSorting)SelectSlides[SelectSlideSongSorting].Selection;
@@ -155,7 +139,6 @@ namespace Vocaluxe.Screens
CSongs.Sorter.SongSorting = CConfig.SongSorting; CSongs.Sorter.SongSorting = CConfig.SongSorting;
CSongs.Categorizer.Tabs = CConfig.Tabs; CSongs.Categorizer.Tabs = CConfig.Tabs;
CLanguage.SetLanguage(CConfig.Language);
} }
} }
} }
+78 -13
View File
@@ -1012,67 +1012,132 @@ namespace Vocaluxe.Menu
#region Elements #region Elements
public void AddBackground(CBackground bg, String key = null) public void AddBackground(CBackground bg)
{
AddBackground(bg, null);
}
public void AddButton(CButton button)
{
AddButton(button, null);
}
public void AddSelectSlide(CSelectSlide slide)
{
AddSelectSlide(slide, null);
}
public void AddStatic(CStatic stat)
{
AddStatic(stat, null);
}
public void AddText(CText text)
{
AddText(text, null);
}
public void AddSongMenu(CSongMenu songmenu)
{
AddSongMenu(songmenu, null);
}
public void AddLyric(CLyric lyric)
{
AddLyric(lyric, null);
}
public void AddSingNote(CSingNotes sn)
{
AddSingNote(sn, null);
}
public void AddNameSelection(CNameSelection ns)
{
AddNameSelection(ns, null);
}
public void AddEqualizer(CEqualizer eq)
{
AddEqualizer(eq, null);
}
public void AddPlaylist(CPlaylist pls)
{
AddPlaylist(pls, null);
}
public void AddParticleEffect(CParticleEffect pe)
{
AddParticleEffect(pe, null);
}
public void AddScreenSetting(CScreenSetting se)
{
AddScreenSetting(se, null);
}
public void AddBackground(CBackground bg, String key)
{ {
_AddInteraction(_Backgrounds.Add(bg, key), EType.TBackground); _AddInteraction(_Backgrounds.Add(bg, key), EType.TBackground);
} }
public void AddButton(CButton button, String key = null) public void AddButton(CButton button, String key)
{ {
_AddInteraction(_Buttons.Add(button, key), EType.TButton); _AddInteraction(_Buttons.Add(button, key), EType.TButton);
} }
public void AddSelectSlide(CSelectSlide slide, String key = null) public void AddSelectSlide(CSelectSlide slide, String key)
{ {
_AddInteraction(_SelectSlides.Add(slide, key), EType.TSelectSlide); _AddInteraction(_SelectSlides.Add(slide, key), EType.TSelectSlide);
} }
public void AddStatic(CStatic stat, String key = null) public void AddStatic(CStatic stat, String key)
{ {
_AddInteraction(_Statics.Add(stat, key), EType.TStatic); _AddInteraction(_Statics.Add(stat, key), EType.TStatic);
} }
public void AddText(CText text, String key = null) public void AddText(CText text, String key)
{ {
_AddInteraction(_Texts.Add(text, key), EType.TText); _AddInteraction(_Texts.Add(text, key), EType.TText);
} }
public void AddSongMenu(CSongMenu songmenu, String key = null) public void AddSongMenu(CSongMenu songmenu, String key)
{ {
_AddInteraction(_SongMenus.Add(songmenu, key), EType.TSongMenu); _AddInteraction(_SongMenus.Add(songmenu, key), EType.TSongMenu);
} }
public void AddLyric(CLyric lyric, String key = null) public void AddLyric(CLyric lyric, String key)
{ {
_AddInteraction(_Lyrics.Add(lyric, key), EType.TLyric); _AddInteraction(_Lyrics.Add(lyric, key), EType.TLyric);
} }
public void AddSingNote(CSingNotes sn, String key = null) public void AddSingNote(CSingNotes sn, String key)
{ {
_AddInteraction(_SingNotes.Add(sn, key), EType.TSingNote); _AddInteraction(_SingNotes.Add(sn, key), EType.TSingNote);
} }
public void AddNameSelection(CNameSelection ns, String key = null) public void AddNameSelection(CNameSelection ns, String key)
{ {
_AddInteraction(_NameSelections.Add(ns, key), EType.TNameSelection); _AddInteraction(_NameSelections.Add(ns, key), EType.TNameSelection);
} }
public void AddEqualizer(CEqualizer eq, String key = null) public void AddEqualizer(CEqualizer eq, String key)
{ {
_AddInteraction(_Equalizers.Add(eq, key), EType.TEqualizer); _AddInteraction(_Equalizers.Add(eq, key), EType.TEqualizer);
} }
public void AddPlaylist(CPlaylist pls, String key = null) public void AddPlaylist(CPlaylist pls, String key)
{ {
_AddInteraction(_Playlists.Add(pls, key), EType.TPlaylist); _AddInteraction(_Playlists.Add(pls, key), EType.TPlaylist);
} }
public void AddParticleEffect(CParticleEffect pe, String key = null) public void AddParticleEffect(CParticleEffect pe, String key)
{ {
_AddInteraction(_ParticleEffects.Add(pe, key), EType.TParticleEffect); _AddInteraction(_ParticleEffects.Add(pe, key), EType.TParticleEffect);
} }
public void AddScreenSetting(CScreenSetting se, String key = null) public void AddScreenSetting(CScreenSetting se, String key)
{ {
_ScreenSettings.Add(se, key); _ScreenSettings.Add(se, key);
} }
+19 -19
View File
@@ -181,15 +181,15 @@ namespace Vocaluxe.Menu
} }
} }
private string _Fon = String.Empty; private string _Font = String.Empty;
public string Fon public string Font
{ {
get { return _Fon; } get { return _Font; }
set set
{ {
if (_Fon != value) if (_Font != value)
{ {
_Fon = value; _Font = value;
_PositionNeedsUpdate = true; _PositionNeedsUpdate = true;
} }
} }
@@ -264,7 +264,7 @@ namespace Vocaluxe.Menu
Align = EAlignment.Left; Align = EAlignment.Left;
HAlign = EHAlignment.Center; HAlign = EHAlignment.Center;
Style = EStyle.Normal; Style = EStyle.Normal;
Fon = "Normal"; Font = "Normal";
Color = new SColorF(); Color = new SColorF();
SColor = new SColorF(); SColor = new SColorF();
@@ -295,7 +295,7 @@ namespace Vocaluxe.Menu
Align = text._Align; Align = text._Align;
HAlign = text._HAlign; HAlign = text._HAlign;
Style = text._Style; Style = text._Style;
Fon = text._Fon; Font = text._Font;
Color = new SColorF(text.Color); Color = new SColorF(text.Color);
SColor = new SColorF(text.SColor); SColor = new SColorF(text.SColor);
@@ -327,7 +327,7 @@ namespace Vocaluxe.Menu
Align = align; Align = align;
HAlign = EHAlignment.Center; HAlign = EHAlignment.Center;
Style = style; Style = style;
Fon = font; Font = font;
Color = new SColorF(r, g, b, a); Color = new SColorF(r, g, b, a);
SColor = new SColorF(r, g, b, a); SColor = new SColorF(r, g, b, a);
@@ -366,7 +366,7 @@ namespace Vocaluxe.Menu
Align = align; Align = align;
HAlign = EHAlignment.Center; HAlign = EHAlignment.Center;
Style = style; Style = style;
Fon = font; Font = font;
Color = new SColorF(r, g, b, a); Color = new SColorF(r, g, b, a);
SColor = new SColorF(r, g, b, a); SColor = new SColorF(r, g, b, a);
@@ -403,7 +403,7 @@ namespace Vocaluxe.Menu
Align = align; Align = align;
HAlign = EHAlignment.Center; HAlign = EHAlignment.Center;
Style = style; Style = style;
Fon = font; Font = font;
Color = col; Color = col;
SColor = new SColorF(col); SColor = new SColorF(col);
@@ -442,7 +442,7 @@ namespace Vocaluxe.Menu
Align = align; Align = align;
HAlign = EHAlignment.Center; HAlign = EHAlignment.Center;
Style = style; Style = style;
Fon = font; Font = font;
Color = col; Color = col;
SColor = new SColorF(col); SColor = new SColorF(col);
@@ -511,7 +511,7 @@ namespace Vocaluxe.Menu
_ThemeLoaded &= xmlReader.TryGetEnumValue<EAlignment>(item + "/Align", ref _Align); _ThemeLoaded &= xmlReader.TryGetEnumValue<EAlignment>(item + "/Align", ref _Align);
xmlReader.TryGetEnumValue<EHAlignment>(item + "/HAlign", ref _HAlign); xmlReader.TryGetEnumValue<EHAlignment>(item + "/HAlign", ref _HAlign);
_ThemeLoaded &= xmlReader.TryGetEnumValue<EStyle>(item + "/Style", ref _Style); _ThemeLoaded &= xmlReader.TryGetEnumValue<EStyle>(item + "/Style", ref _Style);
_ThemeLoaded &= xmlReader.GetValue(item + "/Font", ref _Fon, "Normal"); _ThemeLoaded &= xmlReader.GetValue(item + "/Font", ref _Font, "Normal");
_ThemeLoaded &= xmlReader.GetValue(item + "/Text", ref _Theme.Text, String.Empty); _ThemeLoaded &= xmlReader.GetValue(item + "/Text", ref _Theme.Text, String.Empty);
@@ -531,7 +531,7 @@ namespace Vocaluxe.Menu
Height = _Height; Height = _Height;
MaxWidth = _MaxWidth; MaxWidth = _MaxWidth;
Text = _Theme.Text; Text = _Theme.Text;
Fon = _Fon; Font = _Font;
Align = _Align; Align = _Align;
HAlign = _HAlign; HAlign = _HAlign;
Style = _Style; Style = _Style;
@@ -612,7 +612,7 @@ namespace Vocaluxe.Menu
writer.WriteElementString("Style", Enum.GetName(typeof(EStyle), Style)); writer.WriteElementString("Style", Enum.GetName(typeof(EStyle), Style));
writer.WriteComment("<Font>: Text font name"); writer.WriteComment("<Font>: Text font name");
writer.WriteElementString("Font", Fon); writer.WriteElementString("Font", Font);
writer.WriteComment("<Text>: Nothing or translation tag"); writer.WriteComment("<Text>: Nothing or translation tag");
if (CBase.Language.TranslationExists(_Theme.Text)) if (CBase.Language.TranslationExists(_Theme.Text))
@@ -658,7 +658,7 @@ namespace Vocaluxe.Menu
if (_PositionNeedsUpdate) if (_PositionNeedsUpdate)
UpdateTextPosition(); UpdateTextPosition();
CBase.Fonts.SetFont(Fon); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
SColorF CurrentColor = new SColorF(Color); SColorF CurrentColor = new SColorF(Color);
@@ -727,7 +727,7 @@ namespace Vocaluxe.Menu
SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha); SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);
CBase.Fonts.SetFont(Fon); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
if (!EditMode) if (!EditMode)
@@ -766,7 +766,7 @@ namespace Vocaluxe.Menu
float x = X + rx; float x = X + rx;
float y = Y + ry; float y = Y + ry;
CBase.Fonts.SetFont(Fon); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
RectangleF bounds = CBase.Fonts.GetTextBounds(this, this.Height); RectangleF bounds = CBase.Fonts.GetTextBounds(this, this.Height);
@@ -813,7 +813,7 @@ namespace Vocaluxe.Menu
SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha); SColorF color = new SColorF(CurrentColor.R, CurrentColor.G, CurrentColor.B, CurrentColor.A * Alpha);
CBase.Fonts.SetFont(Fon); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
if (!EditMode) if (!EditMode)
@@ -877,7 +877,7 @@ namespace Vocaluxe.Menu
if (_Text.Length == 0) if (_Text.Length == 0)
return; return;
CBase.Fonts.SetFont(Fon); CBase.Fonts.SetFont(Font);
CBase.Fonts.SetStyle(Style); CBase.Fonts.SetStyle(Style);
float h = Height; float h = Height;
+7 -1
View File
@@ -8,10 +8,17 @@ namespace Vocaluxe.Menu
public class CXMLReader public class CXMLReader
{ {
private XPathNavigator _Navigator; private XPathNavigator _Navigator;
private String _FileName;
public string FileName
{
get { return _FileName; }
}
//Private method. Use OpenFile factory method to get an instance //Private method. Use OpenFile factory method to get an instance
private CXMLReader(string uri) private CXMLReader(string uri)
{ {
_FileName = uri;
XPathDocument xPathDoc = new XPathDocument(uri); XPathDocument xPathDoc = new XPathDocument(uri);
_Navigator = xPathDoc.CreateNavigator(); _Navigator = xPathDoc.CreateNavigator();
} }
@@ -94,7 +101,6 @@ namespace Vocaluxe.Menu
results++; results++;
} }
if ((results == 0) || (results > 1)) if ((results == 0) || (results > 1))
{ {
Value = DefaultValue; Value = DefaultValue;
+1 -1
View File
@@ -31,7 +31,7 @@ namespace Vocaluxe.PartyModes
Warning.Height = 100f; Warning.Height = 100f;
Warning.X = 150; Warning.X = 150;
Warning.Y = 300; Warning.Y = 300;
Warning.Fon = "Normal"; Warning.Font = "Normal";
Warning.Style = EStyle.Normal; Warning.Style = EStyle.Normal;
Warning.Color = new SColorF(1f, 0f, 0f, 1f); Warning.Color = new SColorF(1f, 0f, 0f, 1f);
Warning.SColor = new SColorF(1f, 0f, 0f, 1f); Warning.SColor = new SColorF(1f, 0f, 0f, 1f);