Remove proxy songmenu class
This commit is contained in:
1 parent
84694ccbe0
commit
903c4fc182
9 files changed
+99
-243
No files matched your search
@@ -160,6 +160,11 @@ namespace Vocaluxe.Base
|
||||
{
|
||||
CConfig.SongMenuChanged += onSongMenuChanged;
|
||||
}
|
||||
|
||||
public void RemoveSongMenuListener(OnSongMenuChanged onSongMenuChanged)
|
||||
{
|
||||
CConfig.SongMenuChanged -= onSongMenuChanged;
|
||||
}
|
||||
}
|
||||
|
||||
class CBsettings : ISettings
|
||||
|
||||
@@ -147,6 +147,12 @@ namespace Vocaluxe.Screens
|
||||
_DragAndDropCover = GetNewStatic();
|
||||
}
|
||||
|
||||
protected override void _OnSongMenuChanged()
|
||||
{
|
||||
base._OnSongMenuChanged();
|
||||
_SongMenu = _SongMenus[_SongMenuName];
|
||||
}
|
||||
|
||||
public override void LoadTheme(string xmlPath)
|
||||
{
|
||||
base.LoadTheme(xmlPath);
|
||||
|
||||
@@ -28,6 +28,7 @@ using VocaluxeLib.Songs;
|
||||
namespace VocaluxeLib
|
||||
{
|
||||
public delegate void OnSongMenuChanged();
|
||||
|
||||
public interface IConfig
|
||||
{
|
||||
EOffOn GetSaveModifiedSongs();
|
||||
@@ -60,6 +61,7 @@ namespace VocaluxeLib
|
||||
|
||||
bool GetLoadOldThemeFiles();
|
||||
void AddSongMenuListener(OnSongMenuChanged onSongMenuChanged);
|
||||
void RemoveSongMenuListener(OnSongMenuChanged onSongMenuChanged);
|
||||
}
|
||||
|
||||
public interface ISettings
|
||||
|
||||
@@ -89,6 +89,12 @@ namespace VocaluxeLib.Menu
|
||||
protected CMenu()
|
||||
{
|
||||
PartyModeID = -1;
|
||||
CBase.Config.AddSongMenuListener(_OnSongMenuChanged);
|
||||
}
|
||||
|
||||
~CMenu()
|
||||
{
|
||||
CBase.Config.RemoveSongMenuListener(_OnSongMenuChanged);
|
||||
}
|
||||
|
||||
public override void Init()
|
||||
@@ -113,6 +119,16 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeScreenSettings = null;
|
||||
}
|
||||
|
||||
protected virtual void _OnSongMenuChanged()
|
||||
{
|
||||
for (int i = 0; i < _SongMenus.Count; i++)
|
||||
{
|
||||
SThemeSongMenu theme = (SThemeSongMenu)_SongMenus[i].GetTheme();
|
||||
_SongMenus[i] = CSongMenuFactory.CreateSongMenu(theme, PartyModeID);
|
||||
_SongMenus[i].LoadSkin();
|
||||
}
|
||||
}
|
||||
|
||||
#region ThemeHandler
|
||||
protected override void _ClearElements()
|
||||
{
|
||||
@@ -201,7 +217,7 @@ namespace VocaluxeLib.Menu
|
||||
_AddSingNote(new CSingNotes(sb, PartyModeID), sb.Name);
|
||||
|
||||
foreach (SThemeSongMenu sm in Theme.SongMenus)
|
||||
_AddSongMenu(new CSongMenu(sm, PartyModeID), sm.Name);
|
||||
_AddSongMenu(CSongMenuFactory.CreateSongMenu(sm, PartyModeID), sm.Name);
|
||||
|
||||
foreach (SThemeStatic st in Theme.Statics)
|
||||
_AddStatic(new CStatic(st, PartyModeID), st.Name);
|
||||
@@ -258,7 +274,14 @@ namespace VocaluxeLib.Menu
|
||||
_LoadThemeElement<CText>(_ThemeTexts, _AddText, xmlReader);
|
||||
_LoadThemeElement<CButton>(_ThemeButtons, _AddButton, xmlReader);
|
||||
_LoadThemeElement<CSelectSlide>(_ThemeSelectSlides, _AddSelectSlide, xmlReader);
|
||||
_LoadThemeElement<CSongMenu>(_ThemeSongMenus, _AddSongMenu, xmlReader);
|
||||
foreach (string elName in _ThemeSongMenus)
|
||||
{
|
||||
ISongMenu element = CSongMenuFactory.CreateSongMenu(PartyModeID);
|
||||
if (element.LoadTheme("//root/" + ThemeName, elName, xmlReader))
|
||||
_AddSongMenu(element, elName);
|
||||
else
|
||||
CBase.Log.LogError("Can't load songmenu \"" + elName + "\" in screen " + ThemeName);
|
||||
}
|
||||
_LoadThemeElement<CSongMenuFramework>(_ThemeSongMenus, _AddSongMenu, xmlReader);
|
||||
_LoadThemeElement<CLyric>(_ThemeLyrics, _AddLyric, xmlReader);
|
||||
_LoadThemeElement<CSingNotes>(_ThemeSingNotes, _AddSingNote, xmlReader);
|
||||
|
||||
@@ -36,6 +36,11 @@ namespace VocaluxeLib.Menu
|
||||
_ParentName = _ParentName.Remove(0, 1);
|
||||
}
|
||||
|
||||
public int Count
|
||||
{
|
||||
get { return _Items.Count; }
|
||||
}
|
||||
|
||||
public T this[int index]
|
||||
{
|
||||
get { return _Items[index]; }
|
||||
|
||||
@@ -1,238 +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 VocaluxeLib.PartyModes;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
public class CSongMenu : ISongMenu
|
||||
{
|
||||
private readonly int _PartyModeID;
|
||||
private ISongMenu _SongMenu;
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated! Only used for old theme loading.
|
||||
/// </summary>
|
||||
/// <param name="partyModeID"></param>
|
||||
public CSongMenu(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_SongMenu = new CSongMenuTileBoard(partyModeID);
|
||||
}
|
||||
|
||||
public CSongMenu(SThemeSongMenu theme, int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_CreateSongMenu(theme);
|
||||
CBase.Config.AddSongMenuListener(_OnSongMenuChanged);
|
||||
}
|
||||
|
||||
#region ISongMenu
|
||||
public bool SmallView
|
||||
{
|
||||
get { return _SongMenu.SmallView; }
|
||||
set { _SongMenu.SmallView = value; }
|
||||
}
|
||||
|
||||
public void Update(SScreenSongOptions songOptions)
|
||||
{
|
||||
_SongMenu.Update(songOptions);
|
||||
}
|
||||
|
||||
public void OnShow()
|
||||
{
|
||||
_SongMenu.OnShow();
|
||||
}
|
||||
|
||||
public void OnHide()
|
||||
{
|
||||
_SongMenu.OnHide();
|
||||
}
|
||||
|
||||
public bool HandleInput(ref SKeyEvent keyEvent, SScreenSongOptions options)
|
||||
{
|
||||
return _SongMenu.HandleInput(ref keyEvent, options);
|
||||
}
|
||||
|
||||
public bool HandleMouse(ref SMouseEvent mouseEvent, SScreenSongOptions songOptions)
|
||||
{
|
||||
return _SongMenu.HandleMouse(ref mouseEvent, songOptions);
|
||||
}
|
||||
|
||||
public void Draw()
|
||||
{
|
||||
_SongMenu.Draw();
|
||||
}
|
||||
|
||||
public bool IsMouseOverSelectedSong(SMouseEvent mEvent)
|
||||
{
|
||||
return _SongMenu.IsMouseOverSelectedSong(mEvent);
|
||||
}
|
||||
|
||||
public int GetPreviewSongNr()
|
||||
{
|
||||
return _SongMenu.GetPreviewSongNr();
|
||||
}
|
||||
|
||||
public int GetSelectedSongNr()
|
||||
{
|
||||
return _SongMenu.GetSelectedSongNr();
|
||||
}
|
||||
|
||||
public CStatic GetSelectedSongCover()
|
||||
{
|
||||
return _SongMenu.GetSelectedSongCover();
|
||||
}
|
||||
|
||||
public void SetSelectedSong(int visibleSongNr)
|
||||
{
|
||||
_SongMenu.SetSelectedSong(visibleSongNr);
|
||||
}
|
||||
|
||||
public int GetSelectedCategory()
|
||||
{
|
||||
return _SongMenu.GetSelectedCategory();
|
||||
}
|
||||
|
||||
public void SetSelectedCategory(int categoryNr)
|
||||
{
|
||||
_SongMenu.SetSelectedCategory(categoryNr);
|
||||
}
|
||||
|
||||
public bool EnterSelectedCategory()
|
||||
{
|
||||
return _SongMenu.EnterSelectedCategory();
|
||||
}
|
||||
|
||||
public int GetPreviewSong()
|
||||
{
|
||||
return _SongMenu.GetPreviewSong();
|
||||
}
|
||||
#endregion ISongMenu
|
||||
|
||||
#region IMenuElement
|
||||
public bool Highlighted
|
||||
{
|
||||
get { return _SongMenu.Highlighted; }
|
||||
set { _SongMenu.Highlighted = value; }
|
||||
}
|
||||
public bool Selected
|
||||
{
|
||||
get { return _SongMenu.Selected; }
|
||||
set { _SongMenu.Selected = value; }
|
||||
}
|
||||
|
||||
public bool Selectable
|
||||
{
|
||||
get { return _SongMenu.Selectable; }
|
||||
}
|
||||
public bool Visible
|
||||
{
|
||||
get { return _SongMenu.Visible; }
|
||||
set { _SongMenu.Visible = value; }
|
||||
}
|
||||
|
||||
public SRectF Rect
|
||||
{
|
||||
get { return _SongMenu.Rect; }
|
||||
}
|
||||
public SRectF MaxRect
|
||||
{
|
||||
get { return _SongMenu.MaxRect; }
|
||||
set { _SongMenu.MaxRect = value; }
|
||||
}
|
||||
#endregion IMenuElement
|
||||
|
||||
#region IThemeable
|
||||
public string GetThemeName()
|
||||
{
|
||||
return _SongMenu.GetThemeName();
|
||||
}
|
||||
|
||||
public object GetTheme()
|
||||
{
|
||||
return _SongMenu.GetTheme();
|
||||
}
|
||||
|
||||
public bool ThemeLoaded
|
||||
{
|
||||
get { return _SongMenu.ThemeLoaded; }
|
||||
}
|
||||
|
||||
public bool LoadTheme(string xmlPath, string elementName, CXmlReader xmlReader)
|
||||
{
|
||||
return _SongMenu.LoadTheme(xmlPath, elementName, xmlReader);
|
||||
}
|
||||
|
||||
public void UnloadSkin()
|
||||
{
|
||||
_SongMenu.UnloadSkin();
|
||||
}
|
||||
|
||||
public void LoadSkin()
|
||||
{
|
||||
_SongMenu.LoadSkin();
|
||||
}
|
||||
|
||||
public void ReloadSkin()
|
||||
{
|
||||
_SongMenu.ReloadSkin();
|
||||
}
|
||||
|
||||
public void MoveElement(int stepX, int stepY)
|
||||
{
|
||||
_SongMenu.MoveElement(stepX, stepY);
|
||||
}
|
||||
|
||||
public void ResizeElement(int stepW, int stepH)
|
||||
{
|
||||
_SongMenu.ResizeElement(stepW, stepH);
|
||||
}
|
||||
#endregion IThemeable
|
||||
|
||||
private void _OnSongMenuChanged()
|
||||
{
|
||||
_CreateSongMenu((SThemeSongMenu)_SongMenu.GetTheme());
|
||||
_SongMenu.LoadSkin();
|
||||
}
|
||||
|
||||
private void _CreateSongMenu(SThemeSongMenu theme)
|
||||
{
|
||||
switch (CBase.Config.GetSongMenuType())
|
||||
{
|
||||
case ESongMenu.TR_CONFIG_LIST:
|
||||
_SongMenu = new CSongMenuList(theme, _PartyModeID);
|
||||
break;
|
||||
|
||||
//case ESongMenu.TR_CONFIG_DREIDEL:
|
||||
// _SongMenu = new CSongMenuDreidel();
|
||||
// break;
|
||||
case ESongMenu.TR_CONFIG_TILE_BOARD:
|
||||
_SongMenu = new CSongMenuTileBoard(theme, _PartyModeID);
|
||||
break;
|
||||
|
||||
//case ESongMenu.TR_CONFIG_BOOK:
|
||||
// _SongMenu = new CSongMenuBook();
|
||||
// break;
|
||||
default:
|
||||
throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
#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;
|
||||
|
||||
namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
public static class CSongMenuFactory
|
||||
{
|
||||
public static ISongMenu CreateSongMenu(SThemeSongMenu theme, int partyModeID)
|
||||
{
|
||||
switch (CBase.Config.GetSongMenuType())
|
||||
{
|
||||
case ESongMenu.TR_CONFIG_LIST:
|
||||
return new CSongMenuList(theme, partyModeID);
|
||||
|
||||
//case ESongMenu.TR_CONFIG_DREIDEL:
|
||||
// _SongMenu = new CSongMenuDreidel();
|
||||
// break;
|
||||
case ESongMenu.TR_CONFIG_TILE_BOARD:
|
||||
return new CSongMenuTileBoard(theme, partyModeID);
|
||||
|
||||
//case ESongMenu.TR_CONFIG_BOOK:
|
||||
// _SongMenu = new CSongMenuBook();
|
||||
// break;
|
||||
}
|
||||
throw new ArgumentException("Invalid songmenu type: " + CBase.Config.GetSongMenuType());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deprecated! Only used for old theme loading.
|
||||
/// </summary>
|
||||
/// <param name="partyModeID"></param>
|
||||
/// <returns></returns>
|
||||
public static ISongMenu CreateSongMenu(int partyModeID)
|
||||
{
|
||||
return new CSongMenuTileBoard(partyModeID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -638,14 +638,13 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public override void LoadSkin()
|
||||
{
|
||||
base.LoadSkin();
|
||||
foreach (IThemeable themeable in _SubElements.OfType<IThemeable>())
|
||||
themeable.LoadSkin();
|
||||
// Those are drawn seperately so they are not in the above list
|
||||
_CoverBig.LoadSkin();
|
||||
_TextBG.LoadSkin();
|
||||
|
||||
Init();
|
||||
base.LoadSkin();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,6 @@
|
||||
<Compile Include="Draw\CTextureRef.cs" />
|
||||
<Compile Include="Menu\IThemeable.cs" />
|
||||
<Compile Include="Menu\SingNotes\CNoteBars.cs" />
|
||||
<Compile Include="Menu\SongMenu\CSongMenu.cs" />
|
||||
<Compile Include="XmlStructs.cs" />
|
||||
<Compile Include="Xml\CTypeExtensions.cs" />
|
||||
<Compile Include="Xml\CXmlDeserializer.cs" />
|
||||
@@ -129,6 +128,7 @@
|
||||
<Compile Include="Menu\SingNotes\CSingNotes.cs" />
|
||||
<Compile Include="Songs\CCategory.cs" />
|
||||
<Compile Include="Songs\CSong.cs" />
|
||||
<Compile Include="Menu\SongMenu\CSongMenuFactory.cs" />
|
||||
<Compile Include="Menu\SongMenu\CSongMenuFramework.cs" />
|
||||
<Compile Include="Menu\SongMenu\CSongMenuTileBoard.cs" />
|
||||
<Compile Include="Menu\SongMenu\ISongMenu.cs" />
|
||||
|
||||
Reference in new issue
Block a user