* Apply R# clean-up for reliability - Migrate to NUnit4 Assert.That - Update dependencise versions - Fix LangVersion to 9.0 (until net core migration) - Reformat code - Apply 'var' style (easier for refactoring) - Remove redundant parentheses - Add braces on every condition blocks (1 line) - Uses new null checking patterns - Uses AutoProperties when possible - Uses string scalar type instead of class - Clean usings - Add .orig files in git ignore - Rename some properties to respect defined conventions and US format definition - ID -> Id - BPM -> Bpm - Finish -> End * Update R# settings according to the clean-up made
127 lines
3.1 KiB
C#
127 lines
3.1 KiB
C#
#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.Xml.Serialization;
|
|
using VocaluxeLib.Draw;
|
|
|
|
namespace VocaluxeLib.Menu
|
|
{
|
|
public enum ESettingType
|
|
{
|
|
Int,
|
|
String,
|
|
Color,
|
|
Texture
|
|
}
|
|
|
|
[XmlType("ScreenSetting")]
|
|
public struct SThemeScreenSetting
|
|
{
|
|
[XmlAttribute(AttributeName = "Name")]
|
|
public string Name;
|
|
public string Value;
|
|
public ESettingType Type;
|
|
}
|
|
|
|
// ReSharper disable ClassNeverInstantiated.Global
|
|
//Instantiated by reflection
|
|
public class CScreenSetting : IThemeable
|
|
// ReSharper restore ClassNeverInstantiated.Global
|
|
{
|
|
private readonly int _PartyModeId;
|
|
|
|
private SThemeScreenSetting _Theme;
|
|
|
|
public string GetThemeName()
|
|
{
|
|
return _Theme.Name;
|
|
}
|
|
|
|
public bool ThemeLoaded { get; }
|
|
|
|
public CScreenSetting(int partyModeId)
|
|
{
|
|
_PartyModeId = partyModeId;
|
|
_Theme = new SThemeScreenSetting();
|
|
ThemeLoaded = false;
|
|
}
|
|
|
|
public CScreenSetting(SThemeScreenSetting theme, int partyModeId)
|
|
{
|
|
_PartyModeId = partyModeId;
|
|
_Theme = theme;
|
|
}
|
|
|
|
public object GetValue()
|
|
{
|
|
switch (_Theme.Type)
|
|
{
|
|
case ESettingType.Int:
|
|
return _GetIntValue();
|
|
|
|
case ESettingType.String:
|
|
return _Theme.Value;
|
|
|
|
case ESettingType.Color:
|
|
return _GetColorValue();
|
|
|
|
case ESettingType.Texture:
|
|
return _GetTextureValue();
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public object GetTheme()
|
|
{
|
|
return _Theme;
|
|
}
|
|
|
|
private int _GetIntValue()
|
|
{
|
|
try
|
|
{
|
|
return Convert.ToInt32(_Theme.Value);
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return -1;
|
|
}
|
|
}
|
|
|
|
private CTextureRef _GetTextureValue()
|
|
{
|
|
return CBase.Themes.GetSkinTexture(_Theme.Value, _PartyModeId);
|
|
}
|
|
|
|
private SColorF _GetColorValue()
|
|
{
|
|
SColorF color;
|
|
CBase.Themes.GetColor(_Theme.Value, _PartyModeId, out color);
|
|
return color;
|
|
}
|
|
|
|
#region Dummy methods for interface
|
|
public void UnloadSkin() { }
|
|
|
|
public void LoadSkin() { }
|
|
|
|
public void ReloadSkin() { }
|
|
#endregion
|
|
}
|
|
} |