From aa0579a4f1bc0cf83ba367155edc56b582965957 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 15 Oct 2014 17:25:37 +0200 Subject: [PATCH] Make partymodes reload their themes Move PartyModeIds into Partymodes Fix bug where wrong text size is used (CalculatedFont is now used) Fix bug where text of the main table in partymodes is displayed wrong --- .../PartyModeChallenge/CPartyModeChallenge.cs | 4 +- .../CPartyScreenChallengeMain.cs | 12 ++- .../CPartyModeChallengeMedley.cs | 4 +- .../CPartyScreenChallengeMedleyMain.cs | 10 +- .../PartyModeTicTacToe/CPartyModeTicTacToe.cs | 4 +- Vocaluxe/Base/CGraphics.cs | 6 +- Vocaluxe/Base/CParty.cs | 97 ++++++++++--------- Vocaluxe/Base/Fonts/CFonts.cs | 2 +- VocaluxeLib/CFont.cs | 7 ++ VocaluxeLib/Menu/CMenu.cs | 71 +++++++++----- VocaluxeLib/Menu/CMenuParty.cs | 6 +- VocaluxeLib/Menu/COrderedDictionaryLite.cs | 6 ++ VocaluxeLib/Menu/CText.cs | 30 ++++-- VocaluxeLib/PartyModes/CPartyMode.cs | 38 +++++++- VocaluxeLib/PartyModes/CPartyModeNone.cs | 4 +- VocaluxeLib/PartyModes/IPartyMode.cs | 6 ++ 16 files changed, 194 insertions(+), 113 deletions(-) diff --git a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs index 2dc24d47..d1d39b53 100644 --- a/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs +++ b/PartyModes/PartyModeChallenge/CPartyModeChallenge.cs @@ -158,8 +158,8 @@ namespace VocaluxeLib.PartyModes.Challenge private SData _GameData; private EStage _Stage; - public CPartyModeChallenge(string folder) - : base(folder) + public CPartyModeChallenge(int id, string folder) + : base(id, folder) { _ScreenSongOptions.Selection.RandomOnly = false; _ScreenSongOptions.Selection.PartyMode = true; diff --git a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs index 9b73f417..4785c32d 100644 --- a/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs +++ b/PartyModes/PartyModeChallenge/CPartyScreenChallengeMain.cs @@ -431,6 +431,8 @@ namespace VocaluxeLib.PartyModes.Challenge private void _BuildRoundsTable() { + if (_RoundsTable.Count == 0) + return; _RoundsTableScrollArea = new SRectF(); const int numPlayerInOneRow = 3; @@ -439,14 +441,14 @@ namespace VocaluxeLib.PartyModes.Challenge if (_NumRoundsVisible > _GameState.Combs.Count) _NumRoundsVisible = _GameState.Combs.Count; - float numberX = _Texts[_TextRoundNumber].X; - float numberY = _Texts[_TextRoundNumber].Y; + float numberX = _RoundsTable[0].Number.X; + float numberY = _RoundsTable[0].Number.Y; _RoundsTableScrollArea.X = numberX; _RoundsTableScrollArea.Y = numberY; - _RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20; + _RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _RoundsTable[0].Number.X - 20; - float delta = _Texts[_TextRoundNumber].Rect.H; + float delta = _RoundsTable[0].Number.Rect.H; //Update statics and texts for rounds foreach (CRoundsTableRow roundRow in _RoundsTable) @@ -479,7 +481,7 @@ namespace VocaluxeLib.PartyModes.Challenge roundRow.TextScores[column].Y = numberY + delta; roundRow.TextScores[column].MaxWidth = maxw; } - numberY = numberY + 2*delta; + numberY = numberY + 2 * delta; } numberY = numberY + delta / 2; } diff --git a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs index 3c12810f..a7a5cbd0 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyModeChallengeMedley.cs @@ -163,8 +163,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley private SData _GameData; private EStage _Stage; - public CPartyModeChallengeMedley(string folder) - : base(folder) + public CPartyModeChallengeMedley(int id, string folder) + : base(id, folder) { _ScreenSongOptions.Selection.RandomOnly = false; _ScreenSongOptions.Selection.PartyMode = true; diff --git a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs index ddc1230a..b1f798a0 100644 --- a/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs +++ b/PartyModes/PartyModeChallengeMedley/CPartyScreenChallengeMedleyMain.cs @@ -431,6 +431,8 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley private void _BuildRoundsTable() { + if (_RoundsTable.Count == 0) + return; _RoundsTableScrollArea = new SRectF(); const int numPlayerInOneRow = 3; @@ -439,14 +441,14 @@ namespace VocaluxeLib.PartyModes.ChallengeMedley if (_NumRoundsVisible > _GameState.Combs.Count) _NumRoundsVisible = _GameState.Combs.Count; - float numberX = _Texts[_TextRoundNumber].X; - float numberY = _Texts[_TextRoundNumber].Y; + float numberX = _RoundsTable[0].Number.X; + float numberY = _RoundsTable[0].Number.Y; _RoundsTableScrollArea.X = numberX; _RoundsTableScrollArea.Y = numberY; - _RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _Texts[_TextRoundNumber].X - 20; + _RoundsTableScrollArea.W = CBase.Settings.GetRenderW() - _RoundsTable[0].Number.X - 20; - float delta = _Texts[_TextRoundNumber].Rect.H; + float delta = _RoundsTable[0].Number.Rect.H; //Update statics and texts for rounds foreach (CRoundsTableRow roundRow in _RoundsTable) diff --git a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs index fa7cb48b..34f5677b 100644 --- a/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs +++ b/PartyModes/PartyModeTicTacToe/CPartyModeTicTacToe.cs @@ -180,8 +180,8 @@ namespace VocaluxeLib.PartyModes.TicTacToe private SData _GameData; private EStage _Stage; - public CPartyModeTicTacToe(string folder) - : base(folder) + public CPartyModeTicTacToe(int id, string folder) + : base(id, folder) { _ScreenSongOptions.Selection.RandomOnly = false; _ScreenSongOptions.Selection.PartyMode = true; diff --git a/Vocaluxe/Base/CGraphics.cs b/Vocaluxe/Base/CGraphics.cs index 792f25cc..9bffea2e 100644 --- a/Vocaluxe/Base/CGraphics.cs +++ b/Vocaluxe/Base/CGraphics.cs @@ -20,8 +20,6 @@ using System.Collections.Generic; using System.Diagnostics; using System.Drawing; using System.Windows.Forms; -using System.IO; -using System.Xml.Serialization; using Vocaluxe.Base.Fonts; using Vocaluxe.Base.ThemeSystem; using Vocaluxe.Screens; @@ -148,6 +146,8 @@ namespace Vocaluxe.Base foreach (IMenu popup in _PopupScreens) popup.ReloadTheme(CThemes.GetThemeScreensPath(popup.PartyModeID)); + + CParty.ReloadTheme(); } public static void ReloadSkin() @@ -158,6 +158,8 @@ namespace Vocaluxe.Base foreach (IMenu menu in _PopupScreens) menu.ReloadTextures(); + + CParty.ReloadTextures(); } public static void SaveTheme() diff --git a/Vocaluxe/Base/CParty.cs b/Vocaluxe/Base/CParty.cs index 244f2335..5ad08d70 100644 --- a/Vocaluxe/Base/CParty.cs +++ b/Vocaluxe/Base/CParty.cs @@ -32,7 +32,6 @@ namespace Vocaluxe.Base #region Structs struct SPartyMode { - public int PartyModeID; public int PartyModeSystemVersion; public string Name; public string Description; @@ -64,9 +63,9 @@ namespace Vocaluxe.Base _NextID = 0; //add dummy normal game mode and set it as default - var pm = new SPartyMode {PartyMode = new CPartyModeNone(null), ScreenFiles = new List(), PartyModeID = _NextID++}; - _NormalGameModeID = pm.PartyModeID; - _PartyModes.Add(pm.PartyModeID, pm); + var pm = new SPartyMode {ScreenFiles = new List(), PartyMode = new CPartyModeNone(_NextID++, null)}; + _NormalGameModeID = pm.PartyMode.ID; + _PartyModes.Add(pm.PartyMode.ID, pm); _CurrentPartyMode = pm; //load other party modes @@ -77,8 +76,8 @@ namespace Vocaluxe.Base { get { - if (_CurrentPartyMode.PartyModeID != _NormalGameModeID) - return _CurrentPartyMode.PartyModeID; + if (_CurrentPartyMode.PartyMode.ID != _NormalGameModeID) + return _CurrentPartyMode.PartyMode.ID; return -1; } @@ -89,45 +88,50 @@ namespace Vocaluxe.Base get { return _PartyModes.Count; } } + public static void ReloadTheme() + { + foreach (SPartyMode pm in _PartyModes.Values) + pm.PartyMode.ReloadTheme(); + } + + public static void ReloadTextures() + { + foreach (SPartyMode pm in _PartyModes.Values) + pm.PartyMode.ReloadTextures(); + } + public static void SaveThemes() { - foreach (KeyValuePair pair in _PartyModes) - pair.Value.PartyMode.SaveScreens(); + foreach (SPartyMode pm in _PartyModes.Values) + pm.PartyMode.SaveScreens(); } public static List GetPartyModeInfos() { var infos = new List(); - var pmIDs = new int[_PartyModes.Count]; - _PartyModes.Keys.CopyTo(pmIDs, 0); - - foreach (int pmID in pmIDs) + foreach (KeyValuePair kvp in _PartyModes) { - if (pmID != _NormalGameModeID) + if (kvp.Key != _NormalGameModeID) { - SPartyMode mode; - _PartyModes.TryGetValue(pmID, out mode); + SPartyMode mode = kvp.Value; - if (mode.PartyMode != null) - { - var info = new SPartyModeInfos - { - Author = mode.Author, - Description = mode.Description, - Name = mode.Name, - PartyModeID = mode.PartyModeID, - VersionMajor = mode.PartyModeVersionMajor, - VersionMinor = mode.PartyModeVersionMinor, - TargetAudience = mode.TargetAudience, - MaxPlayers = mode.PartyMode.GetMaxPlayer(), - MinPlayers = mode.PartyMode.GetMinPlayer(), - MaxTeams = mode.PartyMode.GetMaxTeams(), - MinTeams = mode.PartyMode.GetMinTeams() - }; + var info = new SPartyModeInfos + { + Author = mode.Author, + Description = mode.Description, + Name = mode.Name, + PartyModeID = mode.PartyMode.ID, + VersionMajor = mode.PartyModeVersionMajor, + VersionMinor = mode.PartyModeVersionMinor, + TargetAudience = mode.TargetAudience, + MaxPlayers = mode.PartyMode.GetMaxPlayer(), + MinPlayers = mode.PartyMode.GetMinPlayer(), + MaxTeams = mode.PartyMode.GetMaxTeams(), + MinTeams = mode.PartyMode.GetMinTeams() + }; - infos.Add(info); - } + infos.Add(info); } } return infos; @@ -225,13 +229,13 @@ namespace Vocaluxe.Base { SPartyMode pm; if (_LoadPartyMode(file, out pm)) - _PartyModes.Add(pm.PartyModeID, pm); + _PartyModes.Add(pm.PartyMode.ID, pm); } } private static bool _LoadPartyMode(string file, out SPartyMode pm) { - pm = new SPartyMode {PartyModeID = _NextID++, ScreenFiles = new List()}; + pm = new SPartyMode {ScreenFiles = new List()}; CXMLReader xmlReader = CXMLReader.OpenFile(file); @@ -280,14 +284,8 @@ namespace Vocaluxe.Base if (output == null) return false; - if (!CLanguage.LoadPartyLanguageFiles(pm.PartyModeID, Path.Combine(pathToPm, CSettings.FolderNamePartyModeLanguages))) - { - CLog.LogError("Error loading language files for PartyMode: " + file); - return false; - } - object instance = output.CreateInstance(typeof(IPartyMode).Namespace + "." + pm.Folder + "." + pm.PartyModeFile, false, - BindingFlags.Public | BindingFlags.Instance,null, new object[]{pathToPm}, null, null); + BindingFlags.Public | BindingFlags.Instance, null, new object[] {_NextID++, pathToPm}, null, null); if (instance == null) { CLog.LogError("Error creating Instance of PartyMode file: " + file); @@ -304,28 +302,31 @@ namespace Vocaluxe.Base return false; } - if (!CThemes.ReadThemesFromFolder(Path.Combine(pathToPm, CSettings.FolderNameThemes), pm.PartyModeID)) + if (!CLanguage.LoadPartyLanguageFiles(pm.PartyMode.ID, Path.Combine(pathToPm, CSettings.FolderNamePartyModeLanguages))) + { + CLog.LogError("Error loading language files for PartyMode: " + file); + return false; + } + + if (!CThemes.ReadThemesFromFolder(Path.Combine(pathToPm, CSettings.FolderNameThemes), pm.PartyMode.ID)) return false; - if (!CThemes.LoadPartymodeTheme(pm.PartyModeID)) + if (!CThemes.LoadPartymodeTheme(pm.PartyMode.ID)) return false; foreach (string screenfile in pm.ScreenFiles) { - string xmlPath = CThemes.GetThemeScreensPath(pm.PartyModeID); CMenuParty screen = _GetPartyScreenInstance(output, screenfile, pm.Folder); if (screen != null) { - screen.Init(); screen.AssignPartyMode(pm.PartyMode); - screen.SetPartyModeID(pm.PartyModeID); - screen.LoadTheme(xmlPath); pm.PartyMode.AddScreen(screen, screenfile); } else return false; } + pm.PartyMode.LoadTheme(); return true; } diff --git a/Vocaluxe/Base/Fonts/CFonts.cs b/Vocaluxe/Base/Fonts/CFonts.cs index b824d071..da60cf4a 100644 --- a/Vocaluxe/Base/Fonts/CFonts.cs +++ b/Vocaluxe/Base/Fonts/CFonts.cs @@ -182,7 +182,7 @@ namespace Vocaluxe.Base.Fonts /// RectangleF object containing the bounds public static RectangleF GetTextBounds(CText text) { - return new RectangleF(text.X, text.Y, GetTextWidth(text.TranslatedText, text.Font), GetTextHeight(text.TranslatedText, text.Font)); + return new RectangleF(text.X, text.Y, GetTextWidth(text.TranslatedText, text.CalculatedFont), GetTextHeight(text.TranslatedText, text.CalculatedFont)); } public static Font GetSystemFont(CFont font) diff --git a/VocaluxeLib/CFont.cs b/VocaluxeLib/CFont.cs index bb8fed4e..09182763 100644 --- a/VocaluxeLib/CFont.cs +++ b/VocaluxeLib/CFont.cs @@ -74,6 +74,13 @@ namespace VocaluxeLib _Height = font.Size; } + public CFont(CFont font) + { + _Name = font._Name; + _Style = font._Style; + _Height = font._Height; + } + public CFont(string fontFamily, EStyle style, float h) { _Name = fontFamily; diff --git a/VocaluxeLib/Menu/CMenu.cs b/VocaluxeLib/Menu/CMenu.cs index a8b2af70..babe28fb 100644 --- a/VocaluxeLib/Menu/CMenu.cs +++ b/VocaluxeLib/Menu/CMenu.cs @@ -20,7 +20,6 @@ using System.Collections.Generic; using System.Drawing; using System.IO; using System.Windows.Forms; -using System.Xml; using System.Xml.Serialization; using VocaluxeLib.Draw; using VocaluxeLib.Menu.SingNotes; @@ -62,7 +61,7 @@ namespace VocaluxeLib.Menu public abstract class CMenu : IMenu { - private List _Interactions; + private readonly List _Interactions; private int _Selection; public string ThemePath { get; private set; } @@ -94,19 +93,19 @@ namespace VocaluxeLib.Menu protected string[] _ThemeParticleEffects; protected string[] _ThemeScreenSettings; - protected COrderedDictionaryLite _Buttons { get; private set; } - protected COrderedDictionaryLite _Texts { get; private set; } - protected COrderedDictionaryLite _Backgrounds { get; private set; } - protected COrderedDictionaryLite _Statics { get; private set; } - protected COrderedDictionaryLite _SelectSlides { get; private set; } - protected COrderedDictionaryLite _SongMenus { get; private set; } - protected COrderedDictionaryLite _Lyrics { get; private set; } - protected COrderedDictionaryLite _SingNotes { get; private set; } - protected COrderedDictionaryLite _NameSelections { get; private set; } - protected COrderedDictionaryLite _Equalizers { get; private set; } - protected COrderedDictionaryLite _Playlists { get; private set; } - protected COrderedDictionaryLite _ParticleEffects { get; private set; } - protected COrderedDictionaryLite _ScreenSettings { get; private set; } + protected readonly COrderedDictionaryLite _Buttons; + protected readonly COrderedDictionaryLite _Texts; + protected readonly COrderedDictionaryLite _Backgrounds; + protected readonly COrderedDictionaryLite _Statics; + protected readonly COrderedDictionaryLite _SelectSlides; + protected readonly COrderedDictionaryLite _SongMenus; + protected readonly COrderedDictionaryLite _Lyrics; + protected readonly COrderedDictionaryLite _SingNotes; + protected readonly COrderedDictionaryLite _NameSelections; + protected readonly COrderedDictionaryLite _Equalizers; + protected readonly COrderedDictionaryLite _Playlists; + protected readonly COrderedDictionaryLite _ParticleEffects; + protected readonly COrderedDictionaryLite _ScreenSettings; // ReSharper restore MemberCanBePrivate.Global protected SRectF _ScreenArea; @@ -115,16 +114,11 @@ namespace VocaluxeLib.Menu get { return _ScreenArea; } } - public virtual void Init() + protected CMenu() { - ThemeName = GetType().Name; - if (ThemeName[0] == 'C' && Char.IsUpper(ThemeName[1])) - ThemeName = ThemeName.Remove(0, 1); - PartyModeID = -1; - _Interactions = new List(); - _Selection = 0; + _Interactions = new List(); _Backgrounds = new COrderedDictionaryLite(this); _Buttons = new COrderedDictionaryLite(this); _Texts = new COrderedDictionaryLite(this); @@ -138,6 +132,15 @@ namespace VocaluxeLib.Menu _Playlists = new COrderedDictionaryLite(this); _ParticleEffects = new COrderedDictionaryLite(this); _ScreenSettings = new COrderedDictionaryLite(this); + } + + public virtual void Init() + { + ThemeName = GetType().Name; + if (ThemeName[0] == 'C' && Char.IsUpper(ThemeName[1])) + ThemeName = ThemeName.Remove(0, 1); + + _Selection = 0; _PrevMouseX = 0; _PrevMouseY = 0; @@ -163,6 +166,24 @@ namespace VocaluxeLib.Menu _ThemeScreenSettings = null; } + private void _ClearElements() + { + _Interactions.Clear(); + _Backgrounds.Clear(); + _Buttons.Clear(); + _Texts.Clear(); + _Statics.Clear(); + _SelectSlides.Clear(); + _SongMenus.Clear(); + _Lyrics.Clear(); + _SingNotes.Clear(); + _NameSelections.Clear(); + _Equalizers.Clear(); + _Playlists.Clear(); + _ParticleEffects.Clear(); + _ScreenSettings.Clear(); + } + protected static void _FadeTo(EScreens nextScreen) { CBase.Graphics.FadeTo(nextScreen); @@ -258,7 +279,7 @@ namespace VocaluxeLib.Menu foreach (SThemeText te in Theme.Texts) _AddText(new CText(te, PartyModeID), te.Name); } - catch (InvalidOperationException e) + catch (InvalidOperationException) { CBase.Log.LogError("Error while reading " + ThemeName + ".xml", true, true); } @@ -348,7 +369,7 @@ namespace VocaluxeLib.Menu Theme.SingNotes.Add(el.GetTheme()); } - if (ThemePath == "" || ThemePath == null) + if (string.IsNullOrEmpty(ThemePath)) return; try @@ -456,7 +477,7 @@ namespace VocaluxeLib.Menu return; UnloadTextures(); - Init(); + _ClearElements(); LoadTheme(xmlPath); } #endregion ThemeHandler diff --git a/VocaluxeLib/Menu/CMenuParty.cs b/VocaluxeLib/Menu/CMenuParty.cs index 96faa6c2..7113f466 100644 --- a/VocaluxeLib/Menu/CMenuParty.cs +++ b/VocaluxeLib/Menu/CMenuParty.cs @@ -24,14 +24,10 @@ namespace VocaluxeLib.Menu { protected IPartyMode _PartyMode; - public void SetPartyModeID(int partyModeID) - { - PartyModeID = partyModeID; - } - public void AssignPartyMode(IPartyMode partyMode) { _PartyMode = partyMode; + PartyModeID = partyMode.ID; } public virtual void DataToScreen(Object data) {} diff --git a/VocaluxeLib/Menu/COrderedDictionaryLite.cs b/VocaluxeLib/Menu/COrderedDictionaryLite.cs index 04199f9a..fdc24a0b 100644 --- a/VocaluxeLib/Menu/COrderedDictionaryLite.cs +++ b/VocaluxeLib/Menu/COrderedDictionaryLite.cs @@ -83,5 +83,11 @@ namespace VocaluxeLib.Menu { return GetEnumerator(); } + + public void Clear() + { + _HtIndex.Clear(); + _Items.Clear(); + } } } \ No newline at end of file diff --git a/VocaluxeLib/Menu/CText.cs b/VocaluxeLib/Menu/CText.cs index 93ff634b..57a651cb 100644 --- a/VocaluxeLib/Menu/CText.cs +++ b/VocaluxeLib/Menu/CText.cs @@ -190,8 +190,6 @@ namespace VocaluxeLib.Menu _Text = translation; if (_EditMode) _Text += "|"; - //Reset height, it might have been reduced in _UpdatePosition - Font.Height = _Theme.FontHeight; _PositionNeedsUpdate = true; } } @@ -238,6 +236,17 @@ namespace VocaluxeLib.Menu } public float Alpha = 1f; + private CFont _CalculatedFont; + + public CFont CalculatedFont + { + get + { + if (_PositionNeedsUpdate) + _UpdateTextPosition(); + return _CalculatedFont; + } + } public CText(int partyModeID) { @@ -257,7 +266,7 @@ namespace VocaluxeLib.Menu _MaxWidth = text._MaxWidth; _Align = text._Align; _ResizeAlign = text._ResizeAlign; - Font = text.Font; //Use setter to set observer + Font = new CFont(text.Font); //Use setter to set observer Color = new SColorF(text.Color); SelColor = new SColorF(text.SelColor); @@ -399,10 +408,10 @@ namespace VocaluxeLib.Menu SColorF currentColor = (Selected) ? SelColor : Color; var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha); - CBase.Fonts.DrawText(_Text, Font, Rect.X, Rect.Y, Z, color); + CBase.Fonts.DrawText(_Text, CalculatedFont, Rect.X, Rect.Y, Z, color); if (ReflectionHeight > 0) - CBase.Fonts.DrawTextReflection(_Text, Font, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight); + CBase.Fonts.DrawTextReflection(_Text, CalculatedFont, Rect.X, Rect.Y, Z, color, ReflectionSpace, ReflectionHeight); if (Selected && (CBase.Settings.GetProgramState() == EProgramState.EditTheme)) CBase.Drawing.DrawRect(new SColorF(0.5f, 1f, 0.5f, 0.5f), new SRectF(Rect.X, Rect.Y, Rect.W, Rect.H, Z)); @@ -413,7 +422,7 @@ namespace VocaluxeLib.Menu SColorF currentColor = (Selected) ? SelColor : Color; var color = new SColorF(currentColor.R, currentColor.G, currentColor.B, currentColor.A * Alpha); - CBase.Fonts.DrawText(Text, Font, Rect.X, Rect.Y, Z, color, begin, end); + CBase.Fonts.DrawText(Text, CalculatedFont, Rect.X, Rect.Y, Z, color, begin, end); if (ReflectionHeight > 0) { @@ -503,10 +512,13 @@ namespace VocaluxeLib.Menu private void _UpdateTextPosition() { + _CalculatedFont = new CFont(Font); + _PositionNeedsUpdate = false; + if (_Text == "") return; - float h = Font.Height; + float h = _CalculatedFont.Height; float y = Y; RectangleF bounds = CBase.Fonts.GetTextBounds(this); @@ -527,7 +539,7 @@ namespace VocaluxeLib.Menu y += step * 0.75f; break; } - Font.Height = h; + _CalculatedFont.Height = h; bounds = CBase.Fonts.GetTextBounds(this); } @@ -546,8 +558,6 @@ namespace VocaluxeLib.Menu _Rect.Y = y; _Rect.W = bounds.Width; _Rect.H = bounds.Height; - - _PositionNeedsUpdate = false; } public void FontChanged() diff --git a/VocaluxeLib/PartyModes/CPartyMode.cs b/VocaluxeLib/PartyModes/CPartyMode.cs index 2153d122..e3023607 100644 --- a/VocaluxeLib/PartyModes/CPartyMode.cs +++ b/VocaluxeLib/PartyModes/CPartyMode.cs @@ -24,22 +24,50 @@ namespace VocaluxeLib.PartyModes public abstract class CPartyMode : IPartyMode { private readonly string _Folder; - protected SScreenSongOptions _ScreenSongOptions; - protected readonly Dictionary _Screens; + public int ID { get; private set; } + protected SScreenSongOptions _ScreenSongOptions = new SScreenSongOptions { Selection = new SSelectionOptions(), Sorting = new SSortingOptions() }; + protected readonly Dictionary _Screens = new Dictionary(); - protected CPartyMode(string folder) + protected CPartyMode(int id,string folder) { - _Screens = new Dictionary(); - _ScreenSongOptions = new SScreenSongOptions {Selection = new SSelectionOptions(), Sorting = new SSortingOptions()}; + ID = id; _Folder = folder; } #region Implementation + public virtual bool Init() { return false; } + public void LoadTheme() + { + string xmlPath = CBase.Themes.GetThemeScreensPath(ID); + foreach (CMenuParty menu in _Screens.Values) + { + menu.Init(); + menu.LoadTheme(xmlPath); + } + } + + public void ReloadTextures() + { + foreach (CMenuParty menu in _Screens.Values) + { + menu.ReloadTextures(); + } + } + + public void ReloadTheme() + { + string xmlPath = CBase.Themes.GetThemeScreensPath(ID); + foreach (CMenuParty menu in _Screens.Values) + { + menu.ReloadTheme(xmlPath); + } + } + public void AddScreen(CMenuParty screen, string screenName) { _Screens.Add(screenName, screen); diff --git a/VocaluxeLib/PartyModes/CPartyModeNone.cs b/VocaluxeLib/PartyModes/CPartyModeNone.cs index 2a90dbd2..db862d2a 100644 --- a/VocaluxeLib/PartyModes/CPartyModeNone.cs +++ b/VocaluxeLib/PartyModes/CPartyModeNone.cs @@ -22,8 +22,8 @@ namespace VocaluxeLib.PartyModes public class CPartyModeNone : CPartyMode { //just a dummy for normal game mode - public CPartyModeNone(string folder) - : base(folder) + public CPartyModeNone(int id, string folder) + : base(id, folder) { _ScreenSongOptions.Selection.RandomOnly = false; _ScreenSongOptions.Selection.PartyMode = false; diff --git a/VocaluxeLib/PartyModes/IPartyMode.cs b/VocaluxeLib/PartyModes/IPartyMode.cs index 52d40054..f5a7eb0c 100644 --- a/VocaluxeLib/PartyModes/IPartyMode.cs +++ b/VocaluxeLib/PartyModes/IPartyMode.cs @@ -82,7 +82,13 @@ namespace VocaluxeLib.PartyModes public interface IPartyMode { + int ID { get; } bool Init(); + + void LoadTheme(); + void ReloadTextures(); + void ReloadTheme(); + void AddScreen(CMenuParty screen, string screenName); void SaveScreens(); void DataFromScreen(string screenName, Object data);