Rewrite Theme Engine

This commit is contained in:
Flamefire committed 2014-10-08 22:29:02 +02:00
1 parent 9e5011374f
commit defb2ca6c7
116 files changed
+1034 -1020

No files matched your search

@@ -4,8 +4,7 @@
<Info>
<Name>Ambient</Name>
<Author>brunzel</Author>
<SkinFolder>Textures</SkinFolder>
<ThemeVersionMajor>0</ThemeVersionMajor>
<ThemeVersionMinor>1</ThemeVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
</Info>
</root>
@@ -4,8 +4,8 @@
<Info>
<Name>Blue</Name>
<Author>brunzel</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>1</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
</Info>
<ColorSchemes>
<Player1Dim>
File renamed without changes.

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 91 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 15 KiB

After

Width:  |  Height:  |  Size: 15 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 816 KiB

After

Width:  |  Height:  |  Size: 816 KiB

@@ -4,8 +4,7 @@
<Info>
<Name>Ambient</Name>
<Author>brunzel</Author>
<SkinFolder>Textures</SkinFolder>
<ThemeVersionMajor>0</ThemeVersionMajor>
<ThemeVersionMinor>1</ThemeVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
</Info>
</root>
@@ -4,10 +4,82 @@
<Info>
<Name>Blue</Name>
<Author>brunzel</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>1</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
</Info>
<ColorSchemes>
<Player1Dim>
<R>0,000</R>
<G>0,000</G>
<B>1,000</B>
<A>0,500</A>
</Player1Dim>
<Player2Dim>
<R>1,000</R>
<G>0,000</G>
<B>0,000</B>
<A>0,500</A>
</Player2Dim>
<Player3Dim>
<R>0,000</R>
<G>1,000</G>
<B>0,000</B>
<A>0,500</A>
</Player3Dim>
<Player4Dim>
<R>0,500</R>
<G>0,000</G>
<B>1,000</B>
<A>0,500</A>
</Player4Dim>
<Player5Dim>
<R>1,000</R>
<G>0,800</G>
<B>0,000</B>
<A>0,500</A>
</Player5Dim>
<Player6Dim>
<R>1,000</R>
<G>0,000</G>
<B>0,500</B>
<A>0,500</A>
</Player6Dim>
<Player1Dim2>
<R>0,000</R>
<G>0,000</G>
<B>1,000</B>
<A>0,400</A>
</Player1Dim2>
<Player2Dim2>
<R>1,000</R>
<G>0,000</G>
<B>0,000</B>
<A>0,400</A>
</Player2Dim2>
<Player3Dim2>
<R>0,000</R>
<G>1,000</G>
<B>0,000</B>
<A>0,400</A>
</Player3Dim2>
<Player4Dim2>
<R>0,500</R>
<G>0,000</G>
<B>1,000</B>
<A>0,400</A>
</Player4Dim2>
<Player5Dim2>
<R>1,000</R>
<G>0,800</G>
<B>0,000</B>
<A>0,400</A>
</Player5Dim2>
<Player6Dim2>
<R>1,000</R>
<G>0,000</G>
<B>0,500</B>
<A>0,400</A>
</Player6Dim2>
<BackgroundColor>
<R>0,000</R>
<G>0,000</G>
@@ -145,6 +217,8 @@
<SelectSlideArrowLeft>SelectSlideArrowLeft.png</SelectSlideArrowLeft>
<SelectSlideArrowRight>SelectSlideArrowRight.png</SelectSlideArrowRight>
<PopupBG>Popup.png</PopupBG>
<RepeatIcon>RepeatIcon.png</RepeatIcon>
<Random>Random.png</Random>
<ScrollUp>ScrollUp.png</ScrollUp>
<ScrollDown>ScrollDown.png</ScrollDown>
<Invisible>Invisible.png</Invisible>
File renamed without changes.

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 91 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 816 KiB

After

Width:  |  Height:  |  Size: 816 KiB

@@ -4,8 +4,7 @@
<Info>
<Name>Ambient</Name>
<Author>brunzel</Author>
<SkinFolder>Textures</SkinFolder>
<ThemeVersionMajor>0</ThemeVersionMajor>
<ThemeVersionMinor>1</ThemeVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
</Info>
</root>
@@ -4,10 +4,82 @@
<Info>
<Name>Blue</Name>
<Author>brunzel</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>1</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>1</VersionMinor>
</Info>
<ColorSchemes>
<Player1Dim>
<R>0,000</R>
<G>0,000</G>
<B>1,000</B>
<A>0,500</A>
</Player1Dim>
<Player2Dim>
<R>1,000</R>
<G>0,000</G>
<B>0,000</B>
<A>0,500</A>
</Player2Dim>
<Player3Dim>
<R>0,000</R>
<G>1,000</G>
<B>0,000</B>
<A>0,500</A>
</Player3Dim>
<Player4Dim>
<R>0,500</R>
<G>0,000</G>
<B>1,000</B>
<A>0,500</A>
</Player4Dim>
<Player5Dim>
<R>1,000</R>
<G>0,800</G>
<B>0,000</B>
<A>0,500</A>
</Player5Dim>
<Player6Dim>
<R>1,000</R>
<G>0,000</G>
<B>0,500</B>
<A>0,500</A>
</Player6Dim>
<Player1Dim2>
<R>0,000</R>
<G>0,000</G>
<B>1,000</B>
<A>0,400</A>
</Player1Dim2>
<Player2Dim2>
<R>1,000</R>
<G>0,000</G>
<B>0,000</B>
<A>0,400</A>
</Player2Dim2>
<Player3Dim2>
<R>0,000</R>
<G>1,000</G>
<B>0,000</B>
<A>0,400</A>
</Player3Dim2>
<Player4Dim2>
<R>0,500</R>
<G>0,000</G>
<B>1,000</B>
<A>0,400</A>
</Player4Dim2>
<Player5Dim2>
<R>1,000</R>
<G>0,800</G>
<B>0,000</B>
<A>0,400</A>
</Player5Dim2>
<Player6Dim2>
<R>1,000</R>
<G>0,000</G>
<B>0,500</B>
<A>0,400</A>
</Player6Dim2>
<BackgroundColor>
<R>0,000</R>
<G>0,000</G>
@@ -145,9 +217,12 @@
<SelectSlideArrowLeft>SelectSlideArrowLeft.png</SelectSlideArrowLeft>
<SelectSlideArrowRight>SelectSlideArrowRight.png</SelectSlideArrowRight>
<PopupBG>Popup.png</PopupBG>
<RepeatIcon>RepeatIcon.png</RepeatIcon>
<Random>Random.png</Random>
<ScrollUp>ScrollUp.png</ScrollUp>
<ScrollDown>ScrollDown.png</ScrollDown>
<Invisible>Invisible.png</Invisible>
<PlayerSelector>PlayerSelector.png</PlayerSelector>
<Plus>Plus.png</Plus>
<Minus>Minus.png</Minus>
</Skins>
File renamed without changes.

Before

Width:  |  Height:  |  Size: 499 B

After

Width:  |  Height:  |  Size: 499 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 91 B

After

Width:  |  Height:  |  Size: 91 B

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 2.0 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 6.5 KiB

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 3.5 KiB

File renamed without changes.

Before

Width:  |  Height:  |  Size: 816 KiB

After

Width:  |  Height:  |  Size: 816 KiB

+2 -3
View File
@@ -4,9 +4,8 @@
<Info>
<Name>Ambient</Name>
<Author>bohning</Author>
<SkinFolder>Ambient</SkinFolder>
<ThemeVersionMajor>0</ThemeVersionMajor>
<ThemeVersionMinor>2</ThemeVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>2</VersionMinor>
</Info>
<Cursor>
<Skin>Cursor</Skin>
+2 -2
View File
@@ -4,8 +4,8 @@
<Info>
<Name>Blue</Name>
<Author>bohning</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>0</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>0</VersionMinor>
</Info>
<Colors>
<Player1>
+2 -2
View File
@@ -4,8 +4,8 @@
<Info>
<Name>Green</Name>
<Author>bohning</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>0</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>0</VersionMinor>
</Info>
<Colors>
<Player1>
+2 -2
View File
@@ -4,8 +4,8 @@
<Info>
<Name>Red</Name>
<Author>bohning</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>0</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>0</VersionMinor>
</Info>
<Colors>
<Player1>
+2 -2
View File
@@ -4,8 +4,8 @@
<Info>
<Name>Yellow</Name>
<Author>bohning</Author>
<SkinVersionMajor>0</SkinVersionMajor>
<SkinVersionMinor>0</SkinVersionMinor>
<VersionMajor>0</VersionMajor>
<VersionMinor>0</VersionMinor>
</Info>
<Colors>
<Player1>
@@ -184,7 +184,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SelectSlides[_SelectSlidePlaylist].Clear();
for (int i = 0; i < playlists.Count; i++)
{
string value = playlists[i] + " (" + CBase.Playlist.GetSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
string value = playlists[i] + " (" + CBase.Playlist.GetSongCount(i) + " " + CBase.Language.Translate("TR_SONGS", PartyModeID) + ")";
_SelectSlides[_SelectSlidePlaylist].AddValue(value);
}
_SelectSlides[_SelectSlidePlaylist].Selection = _Data.ScreenConfig.PlaylistID;
@@ -196,7 +196,7 @@ namespace VocaluxeLib.PartyModes.TicTacToe
_SelectSlides[_SelectSlideCategory].Clear();
for (int i = 0; i < categories.Length; i++)
{
string value = categories[i] + " (" + CBase.Songs.GetNumSongsNotSungInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", _PartyModeID) + ")";
string value = categories[i] + " (" + CBase.Songs.GetNumSongsNotSungInCategory(i) + " " + CBase.Language.Translate("TR_SONGS", PartyModeID) + ")";
_SelectSlides[_SelectSlideCategory].AddValue(value);
}
_SelectSlides[_SelectSlideCategory].Selection = _Data.ScreenConfig.CategoryID;
@@ -350,13 +350,13 @@ namespace VocaluxeLib.PartyModes.TicTacToe
if (winner > 0)
{
_Texts[_TextFinishMessage].Color = CBase.Themes.GetPlayerColor(winner);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", _PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " +
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_WINNER", PartyModeID) + " " + CBase.Language.Translate("TR_TEAM", PartyModeID) + " " +
winner;
}
else
{
_Texts[_TextFinishMessage].Color = new SColorF(1, 1, 1, 1);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", _PartyModeID);
_Texts[_TextFinishMessage].Text = CBase.Language.Translate("TR_SCREENMAIN_NOWINNER", PartyModeID);
}
_SetInteractionToButton(_Buttons[_ButtonExit]);
}
@@ -601,8 +601,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe
private void _UpdateTeamChoosingMessage()
{
_Texts[_TextTeamChoosing].Color = CBase.Themes.GetPlayerColor(_GameData.Team + 1);
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", _PartyModeID) + " " + (_GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", _PartyModeID);
_Texts[_TextTeamChoosing].Text = CBase.Language.Translate("TR_TEAM", PartyModeID) + " " + (_GameData.Team + 1) + "! " +
CBase.Language.Translate("TR_SCREENMAIN_TEAM_CHOOSE", PartyModeID);
if (_Status == EStatus.JokerRetry || _Status == EStatus.FieldChoosing)
_Texts[_TextTeamChoosing].Visible = true;
else
+6 -4
View File
@@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
using System.Drawing;
using Vocaluxe.Base.ThemeSystem;
using VocaluxeLib;
using VocaluxeLib.Draw;
@@ -86,11 +87,12 @@ namespace Vocaluxe.Base
public void LoadTextures()
{
_Cursor = CDraw.CopyTexture(CThemes.GetSkinTexture(CThemes.Cursor.SkinName, -1));
SThemeCursor theme = CThemes.GetCursorTheme();
_Cursor = CDraw.CopyTexture(CThemes.GetSkinTexture(theme.SkinName, -1));
CThemes.Cursor.Color.Get(-1, out _Cursor.Color);
_Cursor.Rect.W = CThemes.Cursor.W;
_Cursor.Rect.H = CThemes.Cursor.H;
theme.Color.Get(-1, out _Cursor.Color);
_Cursor.Rect.W = theme.W;
_Cursor.Rect.H = theme.H;
_Cursor.Rect.Z = CSettings.ZNear;
}
+7 -7
View File
@@ -23,6 +23,7 @@ using System.Windows.Forms;
using System.IO;
using System.Xml.Serialization;
using Vocaluxe.Base.Fonts;
using Vocaluxe.Base.ThemeSystem;
using Vocaluxe.Screens;
using VocaluxeLib;
using VocaluxeLib.Menu;
@@ -128,14 +129,14 @@ namespace Vocaluxe.Base
{
CLog.StartBenchmark("Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
_Screens[i].Init();
_Screens[i].LoadTheme(CThemes.GetThemeScreensPath(-1));
_Screens[i].LoadTheme(CThemes.GetThemeScreensPath(_Screens[i].PartyModeID));
CLog.StopBenchmark("Load Theme " + Enum.GetNames(typeof(EScreens))[i]);
}
foreach (IMenu popup in _PopupScreens)
{
popup.Init();
popup.LoadTheme(CThemes.GetThemeScreensPath(-1));
popup.LoadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID));
}
}
@@ -143,10 +144,10 @@ namespace Vocaluxe.Base
{
_Cursor.ReloadTextures();
foreach (IMenu screen in _Screens)
screen.ReloadTheme(CThemes.GetThemeScreensPath(-1));
screen.ReloadTheme(CThemes.GetThemeScreensPath(screen.PartyModeID));
foreach (IMenu popup in _PopupScreens)
popup.ReloadTheme(CThemes.GetThemeScreensPath(-1));
popup.ReloadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID));
}
public static void ReloadSkin()
@@ -161,7 +162,6 @@ namespace Vocaluxe.Base
public static void SaveTheme()
{
CThemes.SaveTheme();
foreach (CMenu screen in _Screens)
{
if (screen.ThemePath == null || screen.ThemeName == "ScreenTest")
@@ -658,13 +658,13 @@ namespace Vocaluxe.Base
}
}
}
CFont font=new CFont("Normal",EStyle.Normal, 25);
CFont font = new CFont("Normal", EStyle.Normal, 25);
SColorF gray = new SColorF(1f, 1f, 1f, 0.5f);
float y = 0;
foreach (string txt in debugOutput)
{
float textWidth = CFonts.GetTextWidth(txt, font);
RectangleF rect = new RectangleF(CSettings.RenderW - textWidth, y, textWidth, CFonts.GetTextHeight(txt,font));
RectangleF rect = new RectangleF(CSettings.RenderW - textWidth, y, textWidth, CFonts.GetTextHeight(txt, font));
CDraw.DrawRect(gray, new SRectF(rect.X, rect.Top, rect.Width, rect.Height, CSettings.ZNear));
CFonts.DrawText(txt, font, rect.X, rect.Y, CSettings.ZNear);
y += rect.Height;
+3 -22
View File
@@ -21,6 +21,7 @@ using System.Collections.ObjectModel;
using System.Drawing;
using System.Xml;
using Vocaluxe.Base.Fonts;
using Vocaluxe.Base.ThemeSystem;
using VocaluxeLib;
using VocaluxeLib.Game;
using VocaluxeLib.Draw;
@@ -272,11 +273,6 @@ namespace Vocaluxe.Base
return CThemes.GetThemeScreensPath(partyModeID);
}
public int GetSkinIndex(int partyModeID)
{
return CThemes.GetSkinIndex(partyModeID);
}
public CTextureRef GetSkinTexture(string textureName, int partyModeID)
{
return CThemes.GetSkinTexture(textureName, partyModeID);
@@ -297,24 +293,9 @@ namespace Vocaluxe.Base
return CThemes.GetPlayerColor(playerNr);
}
public void UnloadSkins()
public void Reload()
{
CThemes.UnloadSkins();
}
public void ListSkins()
{
CThemes.ListSkins();
}
public void LoadSkins()
{
CThemes.LoadSkins();
}
public void LoadTheme()
{
CThemes.LoadTheme();
CThemes.Reload();
}
}
+4 -10
View File
@@ -20,6 +20,7 @@ using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using Vocaluxe.Base.ThemeSystem;
using VocaluxeLib;
using VocaluxeLib.Menu;
using VocaluxeLib.PartyModes;
@@ -311,22 +312,15 @@ namespace Vocaluxe.Base
pm.PartyMode.Initialize();
pm.PartyMode.SetFolder(pathToPm);
if (!CThemes.AddTheme(Path.Combine(pathToPm, "Theme.xml"), pm.PartyModeID))
if (!CThemes.ReadThemesFromFolder(Path.Combine(pathToPm, CSettings.FolderNameThemes), pm.PartyModeID))
return pm;
int themeIndex = CThemes.GetThemeIndex(pm.PartyModeID);
CThemes.ListSkins(themeIndex);
int skinIndex = CThemes.GetSkinIndex(pm.PartyModeID);
if (!CThemes.LoadSkin(skinIndex))
return pm;
if (!CThemes.LoadTheme(themeIndex))
if (!CThemes.LoadPartymodeTheme(pm.PartyModeID))
return pm;
foreach (string screenfile in pm.ScreenFiles)
{
string xmlPath = Path.Combine(pathToPm, CSettings.FolderNamePartyModeScreens);
string xmlPath = CThemes.GetThemeScreensPath(pm.PartyModeID);
CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Folder);
if (screen != null)
+5 -3
View File
@@ -53,8 +53,6 @@ namespace Vocaluxe.Base
//Adjusting of programName and version now in the assembly config.
//I'd use the major and minor for Main releases, build number for every public release and revision for every bugfix version without any features
//As it is different than before, this is open for discussion.
//TODO: Remove this when this is decided
private const string _ProgramCodeName = "Shining Heaven";
public const ERevision VersionRevision = ERevision.Beta;
@@ -114,7 +112,6 @@ namespace Vocaluxe.Base
public const string FolderNamePartyModes = "PartyModes";
public const string FolderNamePartyModeCode = "Code";
public const string FolderNamePartyModeScreens = "Screens";
public const string FolderNamePartyModeLanguages = "Languages";
public const string FolderNamePartyModeFonts = "Fonts";
@@ -123,6 +120,11 @@ namespace Vocaluxe.Base
public const string LinkWebOSApp = "https://build.phonegap.com/apps/639714/download/webos/?qr_key=uY98ymvTr6K144RyTdhs";
public const string LinkWindowsPhoneApp = "https://build.phonegap.com/apps/639714/download/winphone/?qr_key=uY98ymvTr6K144RyTdhs";
/// <summary>
/// Default name for themes, skins...
/// </summary>
public const string DefaultName = "Default";
//public const String[] ToneStrings = new String[]{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" };
public const int ToneMin = -36;
public const int ToneMax = 89;
-291
View File
@@ -1,291 +0,0 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Xml;
using VocaluxeLib;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base
{
class CSkinElement
{
public string Value;
public CTextureRef Texture;
}
class CVideoSkinElement
{
public string Value;
public CVideoStream VideoStream;
}
class CSkin
{
private const int _SkinSystemVersion = 3;
private readonly string _Folder;
private readonly string _FileName;
public readonly int PartyModeID;
public string Name;
private string _Author;
private int _SkinVersionMajor;
private int _SkinVersionMinor;
public readonly Dictionary<string, CSkinElement> SkinList = new Dictionary<string, CSkinElement>();
public readonly Dictionary<string, CVideoSkinElement> VideoList = new Dictionary<string, CVideoSkinElement>();
private readonly Dictionary<string, SColorF> _ColorSchemes = new Dictionary<string, SColorF>();
private SColorF?[] _PlayerColors;
public CSkin(string folder, string file, int partyModeId)
{
_Folder = folder;
_FileName = file;
PartyModeID = partyModeId;
}
#region Load/Save
public bool Init()
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Folder, _FileName));
if (xmlReader == null)
return false;
int version = 0;
if (!xmlReader.TryGetIntValue("//root/SkinSystemVersion", ref version) || version != _SkinSystemVersion)
{
string msg = "Can't load Skin \"" + _FileName + "\", ";
if (version < _SkinSystemVersion)
msg += "the file ist outdated! ";
else
msg += "the file is for newer program versions! ";
msg += "Current SkinSystemVersion is " + _SkinSystemVersion;
CLog.LogError(msg);
return false;
}
bool ok = xmlReader.GetValue("//root/Info/Name", out Name);
ok &= xmlReader.GetValue("//root/Info/Author", out _Author, String.Empty);
ok &= xmlReader.TryGetIntValue("//root/Info/SkinVersionMajor", ref _SkinVersionMajor);
ok &= xmlReader.TryGetIntValue("//root/Info/SkinVersionMinor", ref _SkinVersionMinor);
if (!ok)
{
CLog.LogError("Can't load skin \"" + _FileName + "\". Invalid file!");
return false;
}
return true;
}
public bool Load()
{
Debug.Assert(SkinList.Count == 0 && VideoList.Count == 0);
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Folder, _FileName));
if (xmlReader == null)
return false;
// load skins/textures
List<string> names = xmlReader.GetNames("//root/Skins/*");
foreach (string name in names)
{
CSkinElement sk = new CSkinElement();
xmlReader.GetValue("//root/Skins/" + name, out sk.Value);
sk.Texture = CDraw.AddTexture(Path.Combine(_Folder, sk.Value));
if (sk.Texture == null)
{
CLog.LogError("Error on loading texture \"" + name + "\": " + sk.Value, true);
return false;
}
SkinList.Add(name, sk);
}
// load videos
names = xmlReader.GetNames("//root/Videos/*");
foreach (string name in names)
{
CVideoSkinElement sk = new CVideoSkinElement();
xmlReader.GetValue("//root/Videos/" + name, out sk.Value);
VideoList.Add(name, sk);
}
// load colors
_LoadColors(xmlReader);
return true;
}
public void Unload()
{
foreach (CSkinElement sk in SkinList.Values)
CDraw.RemoveTexture(ref sk.Texture);
foreach (CVideoSkinElement vsk in VideoList.Values)
{
CVideo.Close(ref vsk.VideoStream);
}
SkinList.Clear();
VideoList.Clear();
_PlayerColors = null;
_ColorSchemes.Clear();
}
private void _LoadColors(CXMLReader xmlReader)
{
if (PartyModeID == -1)
{
_PlayerColors = new SColorF?[CSettings.MaxNumPlayer];
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
SColorF color;
if (xmlReader.TryGetColorFromRGBA("//root/Colors/Player" + (i + 1), out color))
_PlayerColors[i] = color;
else
_PlayerColors[i] = null;
}
}
List<string> names = xmlReader.GetNames("//root/ColorSchemes/*");
foreach (string str in names)
{
SColorF color;
if (xmlReader.TryGetColorFromRGBA("//root/ColorSchemes/" + str, out color))
_ColorSchemes.Add(str, color);
}
}
public void SaveSkin()
{
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Folder, _FileName), CConfig.XMLSettings))
{
writer.WriteStartDocument();
writer.WriteStartElement("root");
// ThemeSystemVersion
writer.WriteElementString("SkinSystemVersion", _SkinSystemVersion.ToString());
writer.WriteStartElement("Info");
writer.WriteElementString("Name", Name);
writer.WriteElementString("Author", _Author);
writer.WriteElementString("SkinVersionMajor", _SkinVersionMajor.ToString());
writer.WriteElementString("SkinVersionMinor", _SkinVersionMinor.ToString());
writer.WriteEndElement();
// save colors
_SaveColors(writer);
writer.WriteStartElement("Skins");
foreach (KeyValuePair<string, CSkinElement> element in SkinList)
writer.WriteElementString(element.Key, element.Value.Value);
writer.WriteEndElement();
writer.WriteStartElement("Videos");
foreach (KeyValuePair<string, CVideoSkinElement> element in VideoList)
writer.WriteElementString(element.Key, element.Value.Value);
writer.WriteEndElement();
// End of File
writer.WriteEndElement(); //end of root
writer.WriteEndDocument();
writer.Flush();
}
}
private void _SaveColors(XmlWriter writer)
{
if (PartyModeID == -1)
{
writer.WriteStartElement("Colors");
for (int i = 0; i < _PlayerColors.Length; i++)
{
SColorF? color = _PlayerColors[i];
if (color == null)
continue;
writer.WriteStartElement("Player" + (i + 1));
writer.WriteElementString("R", color.Value.R.ToString("#0.000"));
writer.WriteElementString("G", color.Value.G.ToString("#0.000"));
writer.WriteElementString("B", color.Value.B.ToString("#0.000"));
writer.WriteElementString("A", color.Value.A.ToString("#0.000"));
writer.WriteEndElement();
}
writer.WriteEndElement();
}
writer.WriteStartElement("ColorSchemes");
foreach (KeyValuePair<string, SColorF> kvp in _ColorSchemes)
{
writer.WriteStartElement(kvp.Key);
writer.WriteElementString("R", kvp.Value.R.ToString("#0.000"));
writer.WriteElementString("G", kvp.Value.G.ToString("#0.000"));
writer.WriteElementString("B", kvp.Value.B.ToString("#0.000"));
writer.WriteElementString("A", kvp.Value.A.ToString("#0.000"));
writer.WriteEndElement();
}
writer.WriteEndElement();
}
#endregion Load/Save
public bool GetColor(string colorName, out SColorF color)
{
return _ColorSchemes.TryGetValue(colorName, out color) || GetPlayerColor(colorName, out color);
}
public bool GetPlayerColor(string playerNrString, out SColorF color)
{
color = new SColorF();
if (playerNrString == null)
return false;
if (playerNrString.StartsWith("Player"))
playerNrString = playerNrString.Substring(6);
int playerNr;
if (!int.TryParse(playerNrString, out playerNr))
return false;
return GetPlayerColor(playerNr, out color);
}
public bool GetPlayerColor(int playerNr, out SColorF color)
{
if (_PlayerColors != null && playerNr >= 1 && playerNr <= _PlayerColors.Length)
{
SColorF? colorTmp = _PlayerColors[playerNr - 1];
if (colorTmp != null)
{
color = colorTmp.Value;
return true;
}
}
color = new SColorF();
return false;
}
public CVideoStream GetVideo(string videoName, bool loop = true)
{
CVideoSkinElement sk;
if (VideoList.TryGetValue(videoName, out sk))
{
if (sk.VideoStream == null || sk.VideoStream.IsClosed())
{
sk.VideoStream = CVideo.Load(Path.Combine(_Folder, sk.Value));
CVideo.SetLoop(sk.VideoStream, loop);
}
return sk.VideoStream;
}
return null;
}
}
}
-469
View File
@@ -1,469 +0,0 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Xml;
using Vocaluxe.Base.Fonts;
using VocaluxeLib;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base
{
#region Structs
struct STheme
{
public string Name;
public string Author;
public string SkinFolder;
public int ThemeVersionMajor;
public int ThemeVersionMinor;
public string Path;
public string FileName;
public int PartyModeID;
}
struct SCursor
{
public string SkinName;
public float W;
public float H;
public SThemeColor Color;
}
#endregion Structs
static class CThemes
{
// Version number for main theme and skin files. Increment it, if you've changed something on the theme files!
private const int _ThemeSystemVersion = 5;
#region Vars
private static readonly List<STheme> _Themes = new List<STheme>();
public static string[] ThemeNames
{
get { return _Themes.Where(th => th.PartyModeID == -1).Select(th => th.Name).ToArray(); }
}
private static readonly List<CSkin> _Skins = new List<CSkin>();
public static string[] SkinNames
{
get { return _Skins.Where(ak => ak.PartyModeID == -1).Select(ak => ak.Name).ToArray(); }
}
public static SCursor Cursor;
#endregion Vars
#region Theme and Skin loading and writing
public static bool Init()
{
_ListThemes();
ListSkins();
return LoadSkins() && LoadTheme();
}
public static void Close()
{
UnloadSkins();
}
public static bool LoadSkins()
{
//Fail if loading of any skin failed or no skin was loaded
//TODO: implement handlers that failing skins are logged and ignored
bool result = false;
for (int index = 0; index < _Skins.Count; index++)
{
if (_Skins[index].PartyModeID == -1)
{
if (LoadSkin(index))
result = true;
else
return false;
}
}
return result;
}
public static bool LoadSkin(int skinIndex)
{
return _Skins[skinIndex].Load();
}
public static void UnloadSkins()
{
for (int i = 0; i < _Skins.Count; i++)
{
if (_Skins[i].PartyModeID != -1)
continue;
_Skins[i].Unload();
_Skins.RemoveAt(i);
i--;
}
}
public static bool LoadTheme()
{
for (int i = 0; i < _Themes.Count; i++)
{
if (_Themes[i].Name == CConfig.Theme && _Themes[i].PartyModeID == -1)
return LoadTheme(i);
}
return false;
}
public static bool LoadTheme(int themeIndex)
{
if (themeIndex < 0 || themeIndex >= _Themes.Count)
{
CLog.LogError("Can't find Theme Index " + themeIndex);
return false;
}
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName));
if (xmlReader == null)
return false;
// Load Cursor
if (_Themes[themeIndex].PartyModeID == -1)
_LoadCursor(xmlReader);
// load fonts
if (_Themes[themeIndex].PartyModeID == -1)
{
CFonts.LoadThemeFonts(
_Themes[themeIndex].Name,
Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder, CSettings.FolderNameThemeFonts),
xmlReader);
}
else
{
CFonts.LoadPartyModeFonts(_Themes[themeIndex].PartyModeID,
Path.Combine(_Themes[themeIndex].Path, CSettings.FolderNamePartyModeFonts),
xmlReader);
}
return true;
}
public static void SaveTheme()
{
SaveSkin();
for (int i = 0; i < _Themes.Count; i++)
{
if (_Themes[i].Name == CConfig.Theme && _Themes[i].PartyModeID == -1 || _Themes[i].PartyModeID != -1)
_SaveTheme(i);
}
}
private static void _SaveTheme(int themeIndex)
{
#region ThemeMainFile
using (XmlWriter writer = XmlWriter.Create(Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].FileName), CConfig.XMLSettings))
{
writer.WriteStartDocument();
writer.WriteStartElement("root");
// ThemeSystemVersion
writer.WriteElementString("ThemeSystemVersion", _ThemeSystemVersion.ToString());
#region Info
writer.WriteStartElement("Info");
writer.WriteElementString("Name", _Themes[themeIndex].Name);
writer.WriteElementString("Author", _Themes[themeIndex].Author);
writer.WriteElementString("SkinFolder", _Themes[themeIndex].SkinFolder);
writer.WriteElementString("ThemeVersionMajor", _Themes[themeIndex].ThemeVersionMajor.ToString());
writer.WriteElementString("ThemeVersionMinor", _Themes[themeIndex].ThemeVersionMinor.ToString());
writer.WriteEndElement();
#endregion Info
// Cursor
if (_Themes[themeIndex].PartyModeID == -1)
_SaveCursor(writer);
// save fonts
if (_Themes[themeIndex].PartyModeID == -1)
CFonts.SaveThemeFonts(_Themes[themeIndex].Name, writer);
// End of File
writer.WriteEndElement(); //end of root
writer.WriteEndDocument();
writer.Flush();
}
#endregion ThemeMainFile
}
public static void SaveSkin()
{
foreach (CSkin skin in _Skins)
skin.SaveSkin();
}
private static void _ListThemes()
{
_Themes.Clear();
string path = Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameThemes);
List<string> files = CHelper.ListFiles(path, "*.xml", false, true);
foreach (string file in files)
AddTheme(file, -1);
}
public static bool AddTheme(string filePath, int partyModeID)
{
CXMLReader xmlReader = CXMLReader.OpenFile(filePath);
if (xmlReader == null)
return false;
var theme = new STheme();
int version = 0;
xmlReader.TryGetIntValue("//root/ThemeSystemVersion", ref version);
if (version == _ThemeSystemVersion)
{
xmlReader.GetValue("//root/Info/Name", out theme.Name, String.Empty);
if (theme.Name != "")
{
xmlReader.GetValue("//root/Info/Author", out theme.Author, String.Empty);
xmlReader.GetValue("//root/Info/SkinFolder", out theme.SkinFolder, String.Empty);
xmlReader.TryGetIntValue("//root/Info/ThemeVersionMajor", ref theme.ThemeVersionMajor);
xmlReader.TryGetIntValue("//root/Info/ThemeVersionMinor", ref theme.ThemeVersionMinor);
theme.Path = Path.GetDirectoryName(filePath);
theme.FileName = Path.GetFileName(filePath);
theme.PartyModeID = partyModeID;
_Themes.Add(theme);
}
}
else
{
string msg = "Can't load Theme \"" + filePath + "\", ";
if (version < _ThemeSystemVersion)
msg += "the file is outdated! ";
else
msg += "the file is for newer program versions! ";
msg += "Current ThemeSystemVersion is " + _ThemeSystemVersion + " but found " + version;
CLog.LogError(msg);
}
return true;
}
public static void ListSkins()
{
int themeIndex = GetThemeIndex(-1);
_Skins.Clear();
if (themeIndex < 0 || themeIndex >= _Themes.Count)
{
CLog.LogError("Error List Skins. Can't find Theme: " + CConfig.Theme);
return;
}
ListSkins(themeIndex);
}
public static void ListSkins(int themeIndex)
{
if (themeIndex < 0 || themeIndex >= _Themes.Count)
{
CLog.LogError("Error List Skins. Can't find Theme index: " + themeIndex);
return;
}
STheme theme = _Themes[themeIndex];
string path = Path.Combine(theme.Path, theme.SkinFolder);
List<string> files = CHelper.ListFiles(path, "*.xml");
foreach (string file in files)
{
CSkin skin = new CSkin(path, file, theme.PartyModeID);
if (skin.Init())
_Skins.Add(skin);
}
}
#endregion Theme and Skin loading and writing
#region Theme and Skin index handling
public static int GetSkinIndex(int partyModeID)
{
for (int i = 0; i < _Skins.Count; i++)
{
if (_Skins[i].PartyModeID == partyModeID && _Skins[i].Name == CConfig.Skin)
return i;
}
if (partyModeID >= 0)
{
for (int i = 0; i < _Skins.Count; i++)
{
if (_Skins[i].PartyModeID == partyModeID)
return i;
}
}
for (int i = 0; i < _Skins.Count; i++)
{
if (_Skins[i].PartyModeID < 0 && _Skins[i].Name == CConfig.Skin)
return i;
}
return -1;
}
private static CSkin _GetSkin(int partyModeID)
{
int index = GetSkinIndex(partyModeID);
return index < 0 ? null : _Skins[index];
}
public static int GetThemeIndex(int partyModeID)
{
for (int i = 0; i < _Themes.Count; i++)
{
if (_Themes[i].PartyModeID == partyModeID && _Themes[i].Name == CConfig.Theme)
return i;
}
if (partyModeID >= 0)
{
for (int i = 0; i < _Themes.Count; i++)
{
if (_Themes[i].PartyModeID == partyModeID)
return i;
}
}
for (int i = 0; i < _Themes.Count; i++)
{
if (_Themes[i].PartyModeID < 0 && _Themes[i].Name == CConfig.Theme)
return i;
}
return -1;
}
public static string GetThemeScreensPath(int partyModeID)
{
string path = String.Empty;
int themeIndex = GetThemeIndex(partyModeID);
if (themeIndex != -1)
path = Path.Combine(_Themes[themeIndex].Path, _Themes[themeIndex].SkinFolder, CSettings.FolderNameScreens);
else
CLog.LogError("Can't find current Theme");
return path;
}
public static CTextureRef GetSkinTexture(string textureName, int partyModeID)
{
int skinIndex = GetSkinIndex(partyModeID);
CSkinElement sk;
if (skinIndex != -1 && textureName != null && _Skins[skinIndex].SkinList.TryGetValue(textureName, out sk))
return sk.Texture;
return null;
}
public static CVideoStream GetSkinVideo(string videoName, int partyModeID, bool loop = true)
{
CSkin skin = _GetSkin(partyModeID);
return skin == null ? null : skin.GetVideo(videoName, loop);
}
#endregion Theme and Skin index handling
#region Cursor save/load
private static void _LoadCursor(CXMLReader xmlReader)
{
string value = String.Empty;
xmlReader.GetValue("//root/Cursor/Skin", out Cursor.SkinName, value);
xmlReader.TryGetFloatValue("//root/Cursor/W", ref Cursor.W);
xmlReader.TryGetFloatValue("//root/Cursor/H", ref Cursor.H);
if (xmlReader.GetValue("//root/Cursor/Color", out value, value))
Cursor.Color.Name = value;
else
{
Cursor.Color.Name = null;
xmlReader.TryGetColorFromRGBA("//root/Cursor", out Cursor.Color.Color);
}
}
private static void _SaveCursor(XmlWriter writer)
{
writer.WriteStartElement("Cursor");
writer.WriteElementString("Skin", Cursor.SkinName);
writer.WriteElementString("W", Cursor.W.ToString("#0.000"));
writer.WriteElementString("H", Cursor.H.ToString("#0.000"));
if (!String.IsNullOrEmpty(Cursor.Color.Name))
writer.WriteElementString("Color", Cursor.Color.Name);
else
{
writer.WriteElementString("R", Cursor.Color.Color.R.ToString("#0.000"));
writer.WriteElementString("G", Cursor.Color.Color.G.ToString("#0.000"));
writer.WriteElementString("B", Cursor.Color.Color.B.ToString("#0.000"));
writer.WriteElementString("A", Cursor.Color.Color.A.ToString("#0.000"));
}
writer.WriteEndElement();
}
#endregion Cursor save/load
#region Color Handling
public static bool GetColor(string colorName, int partyModeID, out SColorF color)
{
int skinIndex = GetSkinIndex(partyModeID);
if (_Skins[skinIndex].GetColor(colorName, out color))
return true;
if (partyModeID < 0)
return false;
return GetColor(colorName, -1, out color);
}
public static SColorF GetPlayerColor(int playerNr)
{
bool dummy;
return GetPlayerColor(playerNr, out dummy);
}
public static SColorF GetPlayerColor(int playerNr, out bool success)
{
return GetPlayerColor(playerNr, GetSkinIndex(-1), out success);
}
public static SColorF GetPlayerColor(int playerNr, int skinIndex, out bool success)
{
SColorF color;
success = _Skins[skinIndex].GetPlayerColor(playerNr, out color);
return color;
}
#endregion Color Handling
}
}
+1
View File
@@ -1,4 +1,5 @@
using System.Diagnostics;
using Vocaluxe.Base.ThemeSystem;
using Vocaluxe.Lib.Video;
using VocaluxeLib;
using VocaluxeLib.Draw;
+16
View File
@@ -418,6 +418,22 @@ namespace Vocaluxe.Base.Fonts
}
}
public static void UnloadPartyModeFonts(int partyModeID)
{
Debug.Assert(partyModeID >= 0);
int index = 0;
while (index < _FontFamilies.Count)
{
if (_FontFamilies[index].PartyModeID == partyModeID)
{
_FontFamilies[index].Dispose();
_FontFamilies.RemoveAt(index);
}
else
index++;
}
}
private static void _BuildGlyphs()
{
const string text = " abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
+214
View File
@@ -0,0 +1,214 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using VocaluxeLib;
using VocaluxeLib.Draw;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base.ThemeSystem
{
class CVideoSkinElement
{
public string FileName;
public CVideoStream VideoStream;
}
class CSkin
{
private const int _SkinSystemVersion = 3;
private readonly string _Folder;
private readonly string _FileName;
public readonly int PartyModeID;
private SInfo _Info;
public String Name
{
get { return _Info.Name; }
}
public readonly Dictionary<string, CTextureRef> Textures = new Dictionary<string, CTextureRef>();
private readonly Dictionary<string, CVideoSkinElement> _Videos = new Dictionary<string, CVideoSkinElement>();
private readonly Dictionary<string, SColorF> _ColorSchemes = new Dictionary<string, SColorF>();
private SColorF[] _PlayerColors;
private bool _IsLoaded;
public CSkin(string folder, string file, int partyModeId)
{
_Folder = folder;
_FileName = file;
PartyModeID = partyModeId;
}
public override string ToString()
{
return Name;
}
#region Load
public bool Init()
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Folder, _FileName));
if (xmlReader == null)
return false;
if (!xmlReader.CheckVersion("//root/SkinSystemVersion", _SkinSystemVersion))
return false;
bool ok = xmlReader.Read("//root/Info", out _Info);
if (!ok)
{
CLog.LogError("Can't load skin \"" + _FileName + "\". Invalid file!");
return false;
}
return true;
}
public bool Load()
{
if (_IsLoaded)
return true;
Debug.Assert(Textures.Count == 0 && _Videos.Count == 0);
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Folder, _FileName));
if (xmlReader == null)
return false;
// load skins/textures
List<string> names = xmlReader.GetNames("//root/Skins/*");
foreach (string name in names)
{
string fileName;
xmlReader.GetValue("//root/Skins/" + name, out fileName);
CTextureRef texture = CDraw.AddTexture(Path.Combine(_Folder, fileName));
if (texture == null)
{
CLog.LogError("Error on loading texture \"" + name + "\": " + fileName, true);
return false;
}
Textures.Add(name, texture);
}
// load videos
names = xmlReader.GetNames("//root/Videos/*");
foreach (string name in names)
{
CVideoSkinElement sk = new CVideoSkinElement();
xmlReader.GetValue("//root/Videos/" + name, out sk.FileName);
if (!File.Exists(Path.Combine(_Folder, sk.FileName)))
{
CLog.LogError("Video \"" + name + "\": (" + sk.FileName + ") not found!", true);
return false;
}
_Videos.Add(name, sk);
}
// load colors
if (_LoadColors(xmlReader))
return false;
_IsLoaded = true;
return true;
}
public void Unload()
{
foreach (CTextureRef tex in Textures.Values)
tex.Dispose();
foreach (CVideoSkinElement vsk in _Videos.Values)
CVideo.Close(ref vsk.VideoStream);
Textures.Clear();
_Videos.Clear();
_PlayerColors = null;
_ColorSchemes.Clear();
_IsLoaded = false;
}
private bool _LoadColors(CXMLReader xmlReader)
{
if (PartyModeID == -1)
{
_PlayerColors = new SColorF[CSettings.MaxNumPlayer];
for (int i = 0; i < CSettings.MaxNumPlayer; i++)
{
SColorF color;
if (!xmlReader.TryGetColorFromRGBA("//root/Colors/Player" + (i + 1), out color))
return false;
_PlayerColors[i] = color;
}
}
List<string> names = xmlReader.GetNames("//root/ColorSchemes/*");
foreach (string str in names)
{
SColorF color;
if (!xmlReader.TryGetColorFromRGBA("//root/ColorSchemes/" + str, out color))
return false;
_ColorSchemes.Add(str, color);
}
return true;
}
#endregion Load
public bool GetColor(string colorName, out SColorF color)
{
return _ColorSchemes.TryGetValue(colorName, out color) || _GetPlayerColor(colorName, out color);
}
private bool _GetPlayerColor(string playerNrString, out SColorF color)
{
color = new SColorF();
if (playerNrString == null)
return false;
if (playerNrString.StartsWith("Player"))
playerNrString = playerNrString.Substring(6);
int playerNr;
if (!int.TryParse(playerNrString, out playerNr))
return false;
return GetPlayerColor(playerNr, out color);
}
public bool GetPlayerColor(int playerNr, out SColorF color)
{
if (_PlayerColors != null && playerNr >= 1 && playerNr <= _PlayerColors.Length)
{
color = _PlayerColors[playerNr - 1];
return true;
}
color = new SColorF();
return false;
}
public CVideoStream GetVideo(string videoName, bool loop = true)
{
CVideoSkinElement sk;
if (_Videos.TryGetValue(videoName, out sk))
{
if (sk.VideoStream == null || sk.VideoStream.IsClosed())
{
sk.VideoStream = CVideo.Load(Path.Combine(_Folder, sk.FileName));
CVideo.SetLoop(sk.VideoStream, loop);
}
return sk.VideoStream;
}
return null;
}
public CTextureRef GetTexture(string name)
{
CTextureRef texture;
Textures.TryGetValue(name, out texture);
return texture;
}
}
}
+189
View File
@@ -0,0 +1,189 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using Vocaluxe.Base.Fonts;
using VocaluxeLib;
using VocaluxeLib.Xml;
namespace Vocaluxe.Base.ThemeSystem
{
struct SThemeCursor
{
public string SkinName;
public float W;
public float H;
public SThemeColor Color;
}
class CTheme
{
// Version number for theme files. Increment it, if you've changed something on the theme files!
private const int _ThemeSystemVersion = 5;
private SInfo _Info;
public String Name
{
get { return _Info.Name; }
}
public string[] SkinNames
{
get { return _Skins.Keys.ToArray(); }
}
private readonly string _Folder;
private readonly string _FileName;
public readonly int PartyModeID;
public SThemeCursor CursorTheme;
public CSkin CurrentSkin { get; private set; }
private readonly Dictionary<String, CSkin> _Skins = new Dictionary<string, CSkin>();
private bool _IsLoaded;
public CTheme(string filePath, int partyModeID)
{
_Folder = Path.GetDirectoryName(filePath);
_FileName = Path.GetFileName(filePath);
PartyModeID = partyModeID;
CurrentSkin = null;
}
public override string ToString()
{
return Name;
}
public bool Init()
{
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Folder, _FileName));
if (xmlReader == null)
return false;
if (!xmlReader.CheckVersion("//root/ThemeSystemVersion", _ThemeSystemVersion))
return false;
bool ok = xmlReader.Read("//root/Info", out _Info);
if (!ok)
{
CLog.LogError("Can't load theme \"" + _FileName + "\". Invalid file!");
return false;
}
string path = Path.Combine(_Folder, Name);
List<string> files = CHelper.ListFiles(path, "*.xml");
// Load skins, succeed if at least 1 skin was loaded
ok = false;
foreach (string file in files)
{
CSkin skin = new CSkin(path, file, PartyModeID);
if (skin.Init())
{
_Skins.Add(skin.Name, skin);
ok = true;
}
}
return ok;
}
public bool Load()
{
if (_IsLoaded)
return true;
CXMLReader xmlReader = CXMLReader.OpenFile(Path.Combine(_Folder, _FileName));
if (xmlReader == null)
return false;
if (!_LoadSkin())
return false;
bool ok;
if (PartyModeID == -1)
{
ok = _LoadCursor(xmlReader);
ok &= CFonts.LoadThemeFonts(Name, Path.Combine(_Folder, Name, CSettings.FolderNameThemeFonts), xmlReader);
}
else
ok = CFonts.LoadPartyModeFonts(PartyModeID, Path.Combine(_Folder, "..", CSettings.FolderNamePartyModeFonts), xmlReader);
_IsLoaded = ok;
return ok;
}
private bool _LoadSkin()
{
CSkin skin;
if (!_Skins.TryGetValue(CConfig.Skin, out skin))
{
if (PartyModeID < 0)
skin = _Skins.Values.FirstOrDefault();
else if (Name == CSettings.DefaultName)
{
if (!_Skins.TryGetValue(CSettings.DefaultName, out skin))
skin = _Skins.Values.FirstOrDefault();
}
}
while (skin != null)
{
if (skin.Load())
break;
skin.Unload();
CLog.LogError("Failed to load skin " + Name + ":" + skin + "! Removing...", true);
_Skins.Remove(skin.Name);
skin = (PartyModeID == -1 || Name == CSettings.DefaultName) ? _Skins.Values.FirstOrDefault() : null;
}
if (skin == null)
return false;
CurrentSkin = skin;
return true;
}
private bool _LoadCursor(CXMLReader xmlReader)
{
bool ok = xmlReader.GetValue("//root/Cursor/Skin", out CursorTheme.SkinName);
ok &= xmlReader.TryGetFloatValue("//root/Cursor/W", ref CursorTheme.W);
ok &= xmlReader.TryGetFloatValue("//root/Cursor/H", ref CursorTheme.H);
if (!xmlReader.GetValue("//root/Cursor/Color/Name", out CursorTheme.Color.Name))
ok &= xmlReader.TryGetColorFromRGBA("//root/Cursor/Color/Color", out CursorTheme.Color.Color);
return ok;
}
public void Unload()
{
if (CurrentSkin != null)
{
CurrentSkin.Unload();
CurrentSkin = null;
}
if (PartyModeID == -1)
CFonts.UnloadThemeFonts(Name);
else
CFonts.UnloadPartyModeFonts(PartyModeID);
_IsLoaded = false;
}
public string GetScreenPath()
{
return Path.Combine(_Folder, Name, CSettings.FolderNameScreens);
}
public void ReloadSkin()
{
if (CurrentSkin != null)
{
CurrentSkin.Unload();
CurrentSkin = null;
}
bool ok = _LoadSkin();
Debug.Assert(ok);
}
}
}
+225
View File
@@ -0,0 +1,225 @@
#region license
// This file is part of Vocaluxe.
//
// Vocaluxe is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Vocaluxe is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using VocaluxeLib;
using VocaluxeLib.Draw;
using System.Diagnostics;
namespace Vocaluxe.Base.ThemeSystem
{
static class CThemes
{
private static readonly List<CTheme> _Themes = new List<CTheme>();
public static string[] ThemeNames
{
get { return _Themes.Where(th => th.PartyModeID == -1).Select(th => th.Name).ToArray(); }
}
public static string[] SkinNames
{
get { return _GetTheme(-1).SkinNames; }
}
public static bool Init()
{
return ReadThemesFromFolder(Path.Combine(CSettings.ProgramFolder, CSettings.FolderNameThemes), -1);
}
public static void Close()
{
Unload();
_Themes.Clear();
}
public static void Unload()
{
foreach (CTheme theme in _Themes)
theme.Unload();
}
/// <summary>
/// Loads the currently selected theme trying all others if current theme failed loading<br />
/// Therefore CConfig.Theme/Skin might be changed!<br />
/// Closes the program on failure!
/// </summary>
public static void Load()
{
CTheme theme = _GetTheme(-1) ?? _Themes.FirstOrDefault(th => th.PartyModeID == -1);
while (theme != null)
{
if (theme.Load())
break;
theme.Unload();
CLog.LogError("Failed to load theme " + theme + "! Removing...", true);
_Themes.Remove(theme);
theme = _Themes.FirstOrDefault(th => th.PartyModeID == -1);
}
if (theme == null)
CLog.LogError("No themes found! Cannot continue!", true, true);
else
{
CConfig.Theme = theme.Name;
CConfig.Skin = theme.CurrentSkin.Name;
int[] ids = _Themes.Select(th => th.PartyModeID).Distinct().ToArray();
foreach (int id in ids.Where(id => id >= 0))
LoadPartymodeTheme(id);
}
}
public static bool LoadPartymodeTheme(int partyModeID)
{
CTheme theme = _GetTheme(partyModeID);
if (theme.Load())
return true;
theme.Unload();
if (theme.Name != CSettings.DefaultName)
{
CLog.LogError("Failed to load theme " + theme + " for partymode! Removing...", true);
_Themes.Remove(theme);
theme = _GetTheme(partyModeID);
if (theme.Load())
return true;
}
CLog.LogError("Failed to load default theme for partymode! Unloading partymode!", true);
foreach (CTheme th in _Themes.Where(th => th.PartyModeID == partyModeID))
th.Unload();
_Themes.RemoveAll(th => th.PartyModeID == partyModeID);
return false;
}
public static void Reload()
{
Unload();
Load();
}
public static void ReloadSkin()
{
_GetTheme(-1).ReloadSkin();
}
public static bool ReadThemesFromFolder(string path, int partyModeID)
{
Debug.Assert(_Themes.Count == 0);
List<string> files = CHelper.ListFiles(path, "*.xml", false, true);
List<CTheme> newThemes = new List<CTheme>();
foreach (string file in files)
{
CTheme theme = new CTheme(file, partyModeID);
if (theme.Init())
newThemes.Add(theme);
}
if (newThemes.Count == 0)
{
CLog.LogError("No valid themes found in " + path);
return false;
}
if (partyModeID >= 0 && newThemes.Count(th => th.Name == CSettings.DefaultName) == 0)
{
CLog.LogError("Partymode misses default theme in " + path);
return false;
}
_Themes.AddRange(newThemes);
return true;
}
private static CTheme _GetTheme(int partyModeID)
{
foreach (CTheme theme in _Themes)
{
if (theme.PartyModeID == partyModeID && theme.Name == CConfig.Theme)
return theme;
}
if (partyModeID >= 0)
{
foreach (CTheme theme in _Themes)
{
if (theme.PartyModeID == partyModeID && theme.Name == CSettings.DefaultName)
return theme;
}
Debug.Assert(false, "Partymode misses default theme, this should be checked during partymode loading!");
}
return null;
}
public static string GetThemeScreensPath(int partyModeID)
{
return _GetTheme(partyModeID).GetScreenPath();
}
private static void _LogMissingElement(CTheme theme, string elType, string elName)
{
CLog.LogError("Skin " + theme + ":" + theme.CurrentSkin + " is missing the " + elType + " \"" + elName + "\"! Expect visual problems!");
}
public static CTextureRef GetSkinTexture(string textureName, int partyModeID)
{
Debug.Assert(!String.IsNullOrEmpty(textureName));
CTheme theme = _GetTheme(partyModeID);
CTextureRef texture = theme.CurrentSkin.GetTexture(textureName);
if (texture == null && partyModeID >= 0)
texture = _GetTheme(-1).CurrentSkin.GetTexture(textureName);
if (texture == null)
_LogMissingElement(theme, "texture", textureName);
return texture;
}
public static CVideoStream GetSkinVideo(string videoName, int partyModeID, bool loop = true)
{
Debug.Assert(!String.IsNullOrEmpty(videoName));
CTheme theme = _GetTheme(partyModeID);
CVideoStream video = theme.CurrentSkin.GetVideo(videoName, loop);
if (video == null && partyModeID >= 0)
video = _GetTheme(-1).CurrentSkin.GetVideo(videoName, loop);
if (video == null)
_LogMissingElement(theme, "video", videoName);
return video;
}
public static SThemeCursor GetCursorTheme()
{
return _GetTheme(-1).CursorTheme;
}
public static bool GetColor(string colorName, int partyModeID, out SColorF color)
{
Debug.Assert(!String.IsNullOrEmpty(colorName));
CTheme theme = _GetTheme(partyModeID);
if (!theme.CurrentSkin.GetColor(colorName, out color) && (partyModeID == -1 || !_GetTheme(-1).CurrentSkin.GetColor(colorName, out color)))
{
_LogMissingElement(theme, "color", colorName);
return false;
}
return true;
}
public static SColorF GetPlayerColor(int playerNr)
{
SColorF color;
if (!_GetTheme(-1).CurrentSkin.GetPlayerColor(playerNr, out color))
CLog.LogError("Invalid color requested: Color for player " + playerNr + ". Expect visual problems!", true);
return color;
}
}
}
+5
View File
@@ -26,6 +26,7 @@ using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Fonts;
using Vocaluxe.Base.Server;
using Vocaluxe.Base.ThemeSystem;
namespace Vocaluxe
{
@@ -187,6 +188,10 @@ namespace Vocaluxe
throw new CLoadingException("theme");
CLog.StopBenchmark("Init Theme");
CLog.StartBenchmark("Load Theme");
CThemes.Load();
CLog.StopBenchmark("Load Theme");
Application.DoEvents();
// Load Cover
+1
View File
@@ -19,6 +19,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.ThemeSystem;
using Vocaluxe.Lib.Sound.Record;
using VocaluxeLib;
using VocaluxeLib.Menu;
+27 -60
View File
@@ -15,9 +15,10 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Fonts;
using Vocaluxe.Base.ThemeSystem;
using VocaluxeLib;
using VocaluxeLib.Menu;
@@ -42,9 +43,7 @@ namespace Vocaluxe.Screens
private const string _ButtonExit = "ButtonExit";
private int _OldCoverTheme;
private int _OldTheme;
private int _OldSkin;
private string _OldCoverTheme;
public override void Init()
{
@@ -68,12 +67,6 @@ namespace Vocaluxe.Screens
{
base.LoadTheme(xmlPath);
_SelectSlides[_SelectSlideTheme].AddValues(CThemes.ThemeNames);
_SelectSlides[_SelectSlideTheme].Selection = CThemes.GetThemeIndex(-1);
_SelectSlides[_SelectSlideSkin].AddValues(CThemes.SkinNames);
_SelectSlides[_SelectSlideSkin].Selection = CThemes.GetSkinIndex(-1);
_SelectSlides[_SelectSlideCover].AddValues(CCover.CoverThemes);
_SelectSlides[_SelectSlideCover].Selection = CCover.GetCoverThemeIndex();
_SelectSlides[_SelectSlideNoteLines].SetValues<EOffOn>((int)CConfig.DrawNoteLines);
@@ -140,9 +133,20 @@ namespace Vocaluxe.Screens
{
base.OnShow();
_OldCoverTheme = CCover.GetCoverThemeIndex();
_OldTheme = CThemes.GetThemeIndex(-1);
_OldSkin = CThemes.GetSkinIndex(-1);
_ResetSlides();
_OldCoverTheme = CConfig.CoverTheme;
}
private void _ResetSlides()
{
_SelectSlides[_SelectSlideTheme].Clear();
_SelectSlides[_SelectSlideTheme].AddValues(CThemes.ThemeNames);
_SelectSlides[_SelectSlideTheme].Selection = Array.IndexOf(CThemes.ThemeNames, CConfig.Theme);
_SelectSlides[_SelectSlideSkin].Clear();
_SelectSlides[_SelectSlideSkin].AddValues(CThemes.SkinNames);
_SelectSlides[_SelectSlideSkin].Selection = Array.IndexOf(CThemes.SkinNames, CConfig.Skin);
}
public override bool UpdateGame()
@@ -150,12 +154,6 @@ namespace Vocaluxe.Screens
return true;
}
public override bool Draw()
{
base.Draw();
return true;
}
private void _Close()
{
_SaveConfig();
@@ -164,8 +162,6 @@ namespace Vocaluxe.Screens
private void _SaveConfig()
{
CConfig.Theme = CThemes.ThemeNames[_SelectSlides[_SelectSlideTheme].Selection];
CConfig.Skin = CThemes.SkinNames[_SelectSlides[_SelectSlideSkin].Selection];
CConfig.CoverTheme = CCover.CoverThemes[_SelectSlides[_SelectSlideCover].Selection];
CConfig.DrawNoteLines = (EOffOn)_SelectSlides[_SelectSlideNoteLines].Selection;
CConfig.DrawToneHelper = (EOffOn)_SelectSlides[_SelectSlideToneHelper].Selection;
@@ -175,59 +171,30 @@ namespace Vocaluxe.Screens
CConfig.SaveConfig();
if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].Selection)
if (_OldCoverTheme != _SelectSlides[_SelectSlideCover].Value)
CCover.ReloadCovers();
if (_OldTheme != _SelectSlides[_SelectSlideTheme].Selection)
{
CConfig.Theme = CThemes.ThemeNames[_SelectSlides[_SelectSlideTheme].Selection];
_OldTheme = _SelectSlides[_SelectSlideTheme].Selection;
CThemes.UnloadSkins();
CFonts.UnloadThemeFonts(CConfig.Theme);
CThemes.ListSkins();
CConfig.Skin = CThemes.SkinNames[0];
_OldSkin = 0;
CConfig.SaveConfig();
CThemes.LoadSkins();
CThemes.LoadTheme();
CGraphics.ReloadTheme();
}
}
private void _OnChange()
{
if (_OldTheme != _SelectSlides[_SelectSlideTheme].Selection)
if (CConfig.Theme != _SelectSlides[_SelectSlideTheme].Value)
{
CConfig.Theme = CThemes.ThemeNames[_SelectSlides[_SelectSlideTheme].Selection];
_OldTheme = _SelectSlides[_SelectSlideTheme].Selection;
CConfig.Theme = _SelectSlides[_SelectSlideTheme].Value;
CThemes.UnloadSkins();
CFonts.UnloadThemeFonts(CConfig.Theme);
CThemes.ListSkins();
CConfig.Skin = CThemes.SkinNames[0];
_OldSkin = 0;
CConfig.SaveConfig();
CThemes.LoadSkins();
CThemes.LoadTheme();
CThemes.Reload();
CGraphics.ReloadTheme();
OnShow();
OnShowFinish();
_ResetSlides();
_ResumeBG();
return;
}
if (_OldSkin != _SelectSlides[_SelectSlideSkin].Selection)
if (CConfig.Skin != _SelectSlides[_SelectSlideSkin].Value)
{
_OldSkin = _SelectSlides[_SelectSlideSkin].Selection;
CConfig.Skin = _SelectSlides[_SelectSlideSkin].Value;
_PauseBG();
CConfig.Skin = CThemes.SkinNames[_OldSkin];
CThemes.ReloadSkin();
CGraphics.ReloadSkin();
_ResetSlides();
_ResumeBG();
}
}
+1
View File
@@ -24,6 +24,7 @@ using System.Linq;
using System.Windows.Forms;
using Vocaluxe.Base;
using Vocaluxe.Base.Fonts;
using Vocaluxe.Base.ThemeSystem;
using Vocaluxe.Lib.Video;
using VocaluxeLib;
using VocaluxeLib.Draw;
+3 -2
View File
@@ -219,8 +219,9 @@
<Compile Include="Base\CNoCoverGenerator.cs" />
<Compile Include="Base\CPlaylistElement.cs" />
<Compile Include="Base\CRecord.cs" />
<Compile Include="Base\ThemeSystem\CTheme.cs" />
<Compile Include="Base\CVideoPlayer.cs" />
<Compile Include="Base\CSkin.cs" />
<Compile Include="Base\ThemeSystem\CSkin.cs" />
<Compile Include="COSFunctions.cs" />
<Compile Include="Lib\Database\CCoverDB.cs" />
<Compile Include="Lib\Database\CDatabaseBase.cs" />
@@ -263,7 +264,7 @@
<Compile Include="Base\CUtility.cs" />
<Compile Include="Base\CSettings.cs" />
<Compile Include="Base\CSongs.cs" />
<Compile Include="Base\CThemes.cs" />
<Compile Include="Base\ThemeSystem\CThemes.cs" />
<Compile Include="Base\CVideo.cs" />
<Compile Include="Base\CWebcam.cs" />
<Compile Include="Base\Fonts\CFonts.cs" />
+1 -6
View File
@@ -101,17 +101,12 @@ namespace VocaluxeLib
public interface IThemes
{
string GetThemeScreensPath(int partyModeID);
int GetSkinIndex(int partyModeID);
CTextureRef GetSkinTexture(string textureName, int partyModeID);
CVideoStream GetSkinVideo(string videoName, int partyModeID, bool loop);
bool GetColor(string colorName, int partyModeID, out SColorF color);
SColorF GetPlayerColor(int playerNr);
void UnloadSkins();
void ListSkins();
void LoadSkins();
void LoadTheme();
void Reload();
}
public interface IBackgroundMusic
+1 -1
View File
@@ -87,7 +87,7 @@ namespace VocaluxeLib.Menu
#endregion Constructors
#region public
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
+3 -3
View File
@@ -162,7 +162,7 @@ namespace VocaluxeLib.Menu
_SelReflectionSpace = button._SelReflectionSpace;
}
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
@@ -196,12 +196,12 @@ namespace VocaluxeLib.Menu
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SA", ref SelColor.A);
}
_ThemeLoaded &= Text.LoadTheme(item, "Text", xmlReader, skinIndex, true);
_ThemeLoaded &= Text.LoadTheme(item, "Text", xmlReader, true);
Text.Z = Rect.Z;
if (xmlReader.ItemExists(item + "/SText"))
{
_Theme.STextSpecified = true;
_ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, skinIndex, true);
_ThemeLoaded &= _SelText.LoadTheme(item, "SText", xmlReader, true);
_SelText.Z = Rect.Z;
}
+1 -1
View File
@@ -109,7 +109,7 @@ namespace VocaluxeLib.Menu
LoadTextures();
}
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
+1 -1
View File
@@ -130,7 +130,7 @@ namespace VocaluxeLib.Menu
LoadTextures();
}
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader)
{
string item = xmlPath + "/" + elementName;
_ThemeLoaded = true;
+60 -65
View File
@@ -65,7 +65,6 @@ namespace VocaluxeLib.Menu
private List<CInteraction> _Interactions;
private int _Selection;
public string ThemePath { get; private set; }
protected int _PartyModeID = -1;
private int _PrevMouseX;
private int _PrevMouseY;
@@ -76,6 +75,7 @@ namespace VocaluxeLib.Menu
protected bool _Active;
protected abstract int _ScreenVersion { get; }
public int PartyModeID { get; protected set; }
public string ThemeName { get; set; }
public STheme Theme;
@@ -121,6 +121,7 @@ namespace VocaluxeLib.Menu
if (ThemeName[0] == 'C' && Char.IsUpper(ThemeName[1]))
ThemeName = ThemeName.Remove(0, 1);
PartyModeID = -1;
_Interactions = new List<CInteraction>();
_Selection = 0;
@@ -170,14 +171,14 @@ namespace VocaluxeLib.Menu
#region ThemeHandler
private delegate void AddElementHandler<in T>(T element, String key);
private void _LoadThemeElement<T>(IEnumerable<string> elements, AddElementHandler<T> addElementHandler, CXMLReader xmlReader, int skinIndex) where T : IMenuElement
private void _LoadThemeElement<T>(IEnumerable<string> elements, AddElementHandler<T> addElementHandler, CXMLReader xmlReader) where T : IMenuElement
{
if (elements != null)
{
foreach (string elName in elements)
{
var element = (T)Activator.CreateInstance(typeof(T), _PartyModeID);
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader, skinIndex))
var element = (T)Activator.CreateInstance(typeof(T), PartyModeID);
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader))
addElementHandler(element, elName);
else
CBase.Log.LogError("Can't load " + typeof(T).Name.Substring(1) + " \"" + elName + "\" in screen " + ThemeName);
@@ -196,7 +197,6 @@ namespace VocaluxeLib.Menu
ThemePath = xmlPath;
string file = Path.Combine(xmlPath, ThemeName + ".xml");
int skinIndex = CBase.Themes.GetSkinIndex(_PartyModeID);
Theme.ScreenInformation = new SScreenInformation();
Theme.Backgrounds = new List<SThemeBackground>();
@@ -220,43 +220,43 @@ namespace VocaluxeLib.Menu
Theme = (STheme)deserializer.Deserialize(textReader);
foreach (SThemeBackground bg in Theme.Backgrounds)
_AddBackground(new CBackground(bg, _PartyModeID), bg.Name);
_AddBackground(new CBackground(bg, PartyModeID), bg.Name);
foreach (SThemeButton bt in Theme.Buttons)
_AddButton(new CButton(bt, _PartyModeID), bt.Name);
_AddButton(new CButton(bt, PartyModeID), bt.Name);
foreach (SThemeEqualizer eq in Theme.Equalizers)
_AddEqualizer(new CEqualizer(eq, _PartyModeID), eq.Name);
_AddEqualizer(new CEqualizer(eq, PartyModeID), eq.Name);
foreach (SThemeLyrics ly in Theme.Lyrics)
_AddLyric(new CLyric(ly, _PartyModeID), ly.Name);
_AddLyric(new CLyric(ly, PartyModeID), ly.Name);
foreach (SThemeNameSelection ns in Theme.NameSelections)
_AddNameSelection(new CNameSelection(ns, _PartyModeID), ns.Name);
_AddNameSelection(new CNameSelection(ns, PartyModeID), ns.Name);
foreach (SThemeParticleEffect pe in Theme.ParticleEffects)
_AddParticleEffect(new CParticleEffect(pe, _PartyModeID), pe.Name);
_AddParticleEffect(new CParticleEffect(pe, PartyModeID), pe.Name);
foreach (SThemePlaylist pl in Theme.Playlists)
_AddPlaylist(new CPlaylist(pl, _PartyModeID), pl.Name);
_AddPlaylist(new CPlaylist(pl, PartyModeID), pl.Name);
foreach (SScreenSetting ss in Theme.ScreenSettings)
_AddScreenSetting(new CScreenSetting(ss, _PartyModeID), ss.Name);
_AddScreenSetting(new CScreenSetting(ss, PartyModeID), ss.Name);
foreach (SThemeSelectSlide sl in Theme.SelectSlides)
_AddSelectSlide(new CSelectSlide(sl, _PartyModeID), sl.Name);
_AddSelectSlide(new CSelectSlide(sl, PartyModeID), sl.Name);
foreach (SThemeSingBar sb in Theme.SingNotes)
_AddSingNote(new CSingNotesClassic(sb, _PartyModeID), sb.Name);
_AddSingNote(new CSingNotesClassic(sb, PartyModeID), sb.Name);
foreach (SThemeSongMenu sm in Theme.SongMenus)
_AddSongMenu(new CSongMenu(sm, _PartyModeID), sm.Name);
_AddSongMenu(new CSongMenu(sm, PartyModeID), sm.Name);
foreach (SThemeStatic st in Theme.Statics)
_AddStatic(new CStatic(st, _PartyModeID), st.Name);
_AddStatic(new CStatic(st, PartyModeID), st.Name);
foreach (SThemeText te in Theme.Texts)
_AddText(new CText(te, _PartyModeID), te.Name);
_AddText(new CText(te, PartyModeID), te.Name);
}
catch (InvalidOperationException e)
{
@@ -278,26 +278,24 @@ namespace VocaluxeLib.Menu
bool versionCheck = _CheckVersion(_ScreenVersion, xmlReader);
int skinIndex = CBase.Themes.GetSkinIndex(_PartyModeID);
if (versionCheck && skinIndex != -1)
if (versionCheck)
{
ThemePath = xmlPath;
_LoadThemeBasics(xmlReader, skinIndex);
_LoadThemeBasics(xmlReader);
_LoadThemeElement<CBackground>(_ThemeBackgrounds, _AddBackground, xmlReader, skinIndex);
_LoadThemeElement<CStatic>(_ThemeStatics, _AddStatic, xmlReader, skinIndex);
_LoadThemeElement<CText>(_ThemeTexts, _AddText, xmlReader, skinIndex);
_LoadThemeElement<CButton>(_ThemeButtons, _AddButton, xmlReader, skinIndex);
_LoadThemeElement<CSelectSlide>(_ThemeSelectSlides, _AddSelectSlide, xmlReader, skinIndex);
_LoadThemeElement<CSongMenu>(_ThemeSongMenus, _AddSongMenu, xmlReader, skinIndex);
_LoadThemeElement<CLyric>(_ThemeLyrics, _AddLyric, xmlReader, skinIndex);
_LoadThemeElement<CSingNotesClassic>(_ThemeSingNotes, _AddSingNote, xmlReader, skinIndex);
_LoadThemeElement<CNameSelection>(_ThemeNameSelections, _AddNameSelection, xmlReader, skinIndex);
_LoadThemeElement<CEqualizer>(_ThemeEqualizers, _AddEqualizer, xmlReader, skinIndex);
_LoadThemeElement<CPlaylist>(_ThemePlaylists, _AddPlaylist, xmlReader, skinIndex);
_LoadThemeElement<CParticleEffect>(_ThemeParticleEffects, _AddParticleEffect, xmlReader, skinIndex);
_LoadThemeElement<CScreenSetting>(_ThemeScreenSettings, _AddScreenSetting, xmlReader, skinIndex);
_LoadThemeElement<CBackground>(_ThemeBackgrounds, _AddBackground, xmlReader);
_LoadThemeElement<CStatic>(_ThemeStatics, _AddStatic, xmlReader);
_LoadThemeElement<CText>(_ThemeTexts, _AddText, xmlReader);
_LoadThemeElement<CButton>(_ThemeButtons, _AddButton, xmlReader);
_LoadThemeElement<CSelectSlide>(_ThemeSelectSlides, _AddSelectSlide, xmlReader);
_LoadThemeElement<CSongMenu>(_ThemeSongMenus, _AddSongMenu, xmlReader);
_LoadThemeElement<CLyric>(_ThemeLyrics, _AddLyric, xmlReader);
_LoadThemeElement<CSingNotesClassic>(_ThemeSingNotes, _AddSingNote, xmlReader);
_LoadThemeElement<CNameSelection>(_ThemeNameSelections, _AddNameSelection, xmlReader);
_LoadThemeElement<CEqualizer>(_ThemeEqualizers, _AddEqualizer, xmlReader);
_LoadThemeElement<CPlaylist>(_ThemePlaylists, _AddPlaylist, xmlReader);
_LoadThemeElement<CParticleEffect>(_ThemeParticleEffects, _AddParticleEffect, xmlReader);
_LoadThemeElement<CScreenSetting>(_ThemeScreenSettings, _AddScreenSetting, xmlReader);
}
Theme.ScreenInformation.ScreenName = ThemeName;
@@ -537,7 +535,7 @@ namespace VocaluxeLib.Menu
// ReSharper disable MemberCanBeProtected.Global
public CButton GetNewButton()
{
return new CButton(_PartyModeID);
return new CButton(PartyModeID);
}
public static CButton GetNewButton(CButton button)
@@ -547,7 +545,7 @@ namespace VocaluxeLib.Menu
public CText GetNewText()
{
return new CText(_PartyModeID);
return new CText(PartyModeID);
}
public static CText GetNewText(CText text)
@@ -562,12 +560,12 @@ namespace VocaluxeLib.Menu
public CBackground GetNewBackground()
{
return new CBackground(_PartyModeID);
return new CBackground(PartyModeID);
}
public CStatic GetNewStatic()
{
return new CStatic(_PartyModeID);
return new CStatic(PartyModeID);
}
public static CStatic GetNewStatic(CStatic oldStatic)
@@ -577,12 +575,12 @@ namespace VocaluxeLib.Menu
public CStatic GetNewStatic(CTextureRef texture, SColorF color, SRectF rect)
{
return new CStatic(_PartyModeID, texture, color, rect);
return new CStatic(PartyModeID, texture, color, rect);
}
public CSelectSlide GetNewSelectSlide()
{
return new CSelectSlide(_PartyModeID);
return new CSelectSlide(PartyModeID);
}
public static CSelectSlide GetNewSelectSlide(CSelectSlide slide)
@@ -592,37 +590,37 @@ namespace VocaluxeLib.Menu
public CSongMenu GetNewSongMenu()
{
return new CSongMenu(_PartyModeID);
return new CSongMenu(PartyModeID);
}
public CLyric GetNewLyric()
{
return new CLyric(_PartyModeID);
return new CLyric(PartyModeID);
}
public CSingNotes GetNewSingNotes()
{
return new CSingNotesClassic(_PartyModeID);
return new CSingNotesClassic(PartyModeID);
}
public CNameSelection GetNewNameSelection()
{
return new CNameSelection(_PartyModeID);
return new CNameSelection(PartyModeID);
}
public CEqualizer GetNewEqualizer()
{
return new CEqualizer(_PartyModeID);
return new CEqualizer(PartyModeID);
}
public CPlaylist GetNewPlaylist()
{
return new CPlaylist(_PartyModeID);
return new CPlaylist(PartyModeID);
}
public CParticleEffect GetNewParticleEffect(int maxNumber, SColorF color, SRectF area, CTextureRef texture, float size, EParticleType type)
{
return new CParticleEffect(_PartyModeID, maxNumber, color, area, texture, size, type);
return new CParticleEffect(PartyModeID, maxNumber, color, area, texture, size, type);
}
// ReSharper restore MemberCanBeProtected.Global
@@ -1901,55 +1899,52 @@ namespace VocaluxeLib.Menu
return false;
}
private void _LoadThemeBasics(CXMLReader xmlReader, int skinIndex)
private void _LoadThemeBasics(CXMLReader xmlReader)
{
// Backgrounds
var background = new CBackground(_PartyModeID);
var background = new CBackground(PartyModeID);
int i = 1;
while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader, skinIndex))
while (background.LoadTheme("//root/" + ThemeName, "Background" + i, xmlReader))
{
_AddBackground(background);
background = new CBackground(_PartyModeID);
background = new CBackground(PartyModeID);
i++;
}
// Statics
var stat = new CStatic(_PartyModeID);
var stat = new CStatic(PartyModeID);
i = 1;
while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader, skinIndex))
while (stat.LoadTheme("//root/" + ThemeName, "Static" + i, xmlReader))
{
_AddStatic(stat);
stat = new CStatic(_PartyModeID);
stat = new CStatic(PartyModeID);
i++;
}
// Texts
var text = new CText(_PartyModeID);
var text = new CText(PartyModeID);
i = 1;
while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader, skinIndex))
while (text.LoadTheme("//root/" + ThemeName, "Text" + i, xmlReader))
{
_AddText(text);
text = new CText(_PartyModeID);
text = new CText(PartyModeID);
i++;
}
// ParticleEffects
var partef = new CParticleEffect(_PartyModeID);
var partef = new CParticleEffect(PartyModeID);
i = 1;
while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader, skinIndex))
while (partef.LoadTheme("//root/" + ThemeName, "ParticleEffect" + i, xmlReader))
{
_AddParticleEffect(partef);
partef = new CParticleEffect(_PartyModeID);
partef = new CParticleEffect(PartyModeID);
i++;
}
}
private void _ReloadThemeEditMode()
{
CBase.Themes.UnloadSkins();
CBase.Themes.ListSkins();
CBase.Themes.LoadSkins();
CBase.Themes.LoadTheme();
CBase.Themes.Reload();
CBase.Graphics.ReloadTheme();
OnShow();
+1 -1
View File
@@ -31,7 +31,7 @@ namespace VocaluxeLib.Menu
public void SetPartyModeID(int partyModeID)
{
_PartyModeID = partyModeID;
PartyModeID = partyModeID;
}
public void AssignPartyMode(IPartyMode partyMode)
Loaded 100 of 116 files, more files were not shown because too many files have changed in this diff. Show more