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
This commit is contained in:
Flamefire committed 2014-10-15 17:25:37 +02:00
1 parent 5d28b19066
commit aa0579a4f1
16 files changed
+194 -113

No files matched your search

+46 -25
View File
@@ -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<CInteraction> _Interactions;
private readonly List<CInteraction> _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<CButton> _Buttons { get; private set; }
protected COrderedDictionaryLite<CText> _Texts { get; private set; }
protected COrderedDictionaryLite<CBackground> _Backgrounds { get; private set; }
protected COrderedDictionaryLite<CStatic> _Statics { get; private set; }
protected COrderedDictionaryLite<CSelectSlide> _SelectSlides { get; private set; }
protected COrderedDictionaryLite<CSongMenu> _SongMenus { get; private set; }
protected COrderedDictionaryLite<CLyric> _Lyrics { get; private set; }
protected COrderedDictionaryLite<CSingNotes> _SingNotes { get; private set; }
protected COrderedDictionaryLite<CNameSelection> _NameSelections { get; private set; }
protected COrderedDictionaryLite<CEqualizer> _Equalizers { get; private set; }
protected COrderedDictionaryLite<CPlaylist> _Playlists { get; private set; }
protected COrderedDictionaryLite<CParticleEffect> _ParticleEffects { get; private set; }
protected COrderedDictionaryLite<CScreenSetting> _ScreenSettings { get; private set; }
protected readonly COrderedDictionaryLite<CButton> _Buttons;
protected readonly COrderedDictionaryLite<CText> _Texts;
protected readonly COrderedDictionaryLite<CBackground> _Backgrounds;
protected readonly COrderedDictionaryLite<CStatic> _Statics;
protected readonly COrderedDictionaryLite<CSelectSlide> _SelectSlides;
protected readonly COrderedDictionaryLite<CSongMenu> _SongMenus;
protected readonly COrderedDictionaryLite<CLyric> _Lyrics;
protected readonly COrderedDictionaryLite<CSingNotes> _SingNotes;
protected readonly COrderedDictionaryLite<CNameSelection> _NameSelections;
protected readonly COrderedDictionaryLite<CEqualizer> _Equalizers;
protected readonly COrderedDictionaryLite<CPlaylist> _Playlists;
protected readonly COrderedDictionaryLite<CParticleEffect> _ParticleEffects;
protected readonly COrderedDictionaryLite<CScreenSetting> _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<CInteraction>();
_Selection = 0;
_Interactions = new List<CInteraction>();
_Backgrounds = new COrderedDictionaryLite<CBackground>(this);
_Buttons = new COrderedDictionaryLite<CButton>(this);
_Texts = new COrderedDictionaryLite<CText>(this);
@@ -138,6 +132,15 @@ namespace VocaluxeLib.Menu
_Playlists = new COrderedDictionaryLite<CPlaylist>(this);
_ParticleEffects = new COrderedDictionaryLite<CParticleEffect>(this);
_ScreenSettings = new COrderedDictionaryLite<CScreenSetting>(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
+1 -5
View File
@@ -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) {}
@@ -83,5 +83,11 @@ namespace VocaluxeLib.Menu
{
return GetEnumerator();
}
public void Clear()
{
_HtIndex.Clear();
_Items.Clear();
}
}
}
+20 -10
View File
@@ -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()