Make SReflection a nullable
This commit is contained in:
1 parent
ad3f01aded
commit
eca0dd68ca
34 files changed
+179
-958
No files matched your search
+15
-12
@@ -16,6 +16,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Xml;
|
||||
@@ -35,8 +36,8 @@ namespace VocaluxeLib.Menu
|
||||
public SThemeText Text;
|
||||
public SThemeText SelText;
|
||||
[XmlIgnore] public bool SelTextSpecified;
|
||||
public SReflection Reflection;
|
||||
public SReflection SelReflection;
|
||||
public SReflection? Reflection;
|
||||
public SReflection? SelReflection;
|
||||
}
|
||||
|
||||
public sealed class CButton : CMenuElementBase, IMenuElement, IThemeable
|
||||
@@ -209,12 +210,12 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
|
||||
|
||||
_Theme.Reflection = new SReflection(true, _ReflectionHeight, _ReflectionSpace);
|
||||
_Theme.Reflection = new SReflection(_ReflectionHeight, _ReflectionSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
_Reflection = false;
|
||||
_Theme.Reflection = new SReflection(false, 0f, 0f);
|
||||
_Theme.Reflection = null;
|
||||
}
|
||||
|
||||
if (xmlReader.ItemExists(item + "/SReflection"))
|
||||
@@ -223,12 +224,12 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Space", ref _SelReflectionSpace);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/SReflection/Height", ref _SelReflectionHeight);
|
||||
|
||||
_Theme.SelReflection = new SReflection(true, _SelReflectionHeight, _SelReflectionSpace);
|
||||
_Theme.SelReflection = new SReflection(_SelReflectionHeight, _SelReflectionSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
_SelReflection = false;
|
||||
_Theme.SelReflection = new SReflection(false, 0f, 0f);
|
||||
_Theme.SelReflection = null;
|
||||
}
|
||||
|
||||
if (_ThemeLoaded)
|
||||
@@ -321,18 +322,20 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
MaxRect = _Theme.Rect;
|
||||
|
||||
_Reflection = _Theme.Reflection.Enabled;
|
||||
_Reflection = _Theme.Reflection.HasValue;
|
||||
if (_Reflection)
|
||||
{
|
||||
_ReflectionHeight = _Theme.Reflection.Height;
|
||||
_ReflectionSpace = _Theme.Reflection.Space;
|
||||
Debug.Assert(_Theme.Reflection != null);
|
||||
_ReflectionHeight = _Theme.Reflection.Value.Height;
|
||||
_ReflectionSpace = _Theme.Reflection.Value.Space;
|
||||
}
|
||||
|
||||
_SelReflection = _Theme.Reflection.Enabled;
|
||||
_SelReflection = _Theme.Reflection.HasValue;
|
||||
if (_SelReflection)
|
||||
{
|
||||
_SelReflectionHeight = _Theme.SelReflection.Height;
|
||||
_SelReflectionSpace = _Theme.SelReflection.Space;
|
||||
Debug.Assert(_Theme.SelReflection != null);
|
||||
_SelReflectionHeight = _Theme.SelReflection.Value.Height;
|
||||
_SelReflectionSpace = _Theme.SelReflection.Value.Space;
|
||||
}
|
||||
|
||||
if (_Theme.Rect.Z < Text.Z)
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Xml;
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public SThemeColor Color;
|
||||
public SThemeColor MaxColor;
|
||||
public SReflection Reflection;
|
||||
public SReflection? Reflection;
|
||||
}
|
||||
|
||||
public class CEqualizer : CMenuElementBase, IMenuElement, IThemeable
|
||||
@@ -148,12 +149,12 @@ namespace VocaluxeLib.Menu
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
|
||||
|
||||
_Theme.Reflection = new SReflection(true, ReflectionHeight, ReflectionSpace);
|
||||
_Theme.Reflection = new SReflection( ReflectionHeight, ReflectionSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
Reflection = false;
|
||||
_Theme.Reflection = new SReflection(false, 0f, 0f);
|
||||
_Theme.Reflection = null;
|
||||
}
|
||||
|
||||
if (_ThemeLoaded)
|
||||
@@ -244,11 +245,12 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
MaxRect = _Theme.Rect;
|
||||
Space = _Theme.Space;
|
||||
Reflection = _Theme.Reflection.Enabled;
|
||||
Reflection = _Theme.Reflection.HasValue;
|
||||
if (Reflection)
|
||||
{
|
||||
ReflectionHeight = _Theme.Reflection.Height;
|
||||
ReflectionSpace = _Theme.Reflection.Space;
|
||||
Debug.Assert(_Theme.Reflection != null);
|
||||
ReflectionHeight = _Theme.Reflection.Value.Height;
|
||||
ReflectionSpace = _Theme.Reflection.Value.Space;
|
||||
}
|
||||
|
||||
_Bars = new float[_Theme.NumBars];
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Serialization;
|
||||
using VocaluxeLib.Draw;
|
||||
using VocaluxeLib.Xml;
|
||||
@@ -29,7 +30,7 @@ namespace VocaluxeLib.Menu
|
||||
public string Skin;
|
||||
public SThemeColor Color;
|
||||
public SRectF Rect;
|
||||
public SReflection Reflection;
|
||||
public SReflection? Reflection;
|
||||
}
|
||||
|
||||
public sealed class CStatic : CMenuElementBase, IMenuElement, IThemeable
|
||||
@@ -147,12 +148,12 @@ namespace VocaluxeLib.Menu
|
||||
Reflection = true;
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref ReflectionSpace);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref ReflectionHeight);
|
||||
_Theme.Reflection = new SReflection(true, ReflectionHeight, ReflectionSpace);
|
||||
_Theme.Reflection = new SReflection(ReflectionHeight, ReflectionSpace);
|
||||
}
|
||||
else
|
||||
{
|
||||
Reflection = false;
|
||||
_Theme.Reflection = new SReflection(false, 0f, 0f);
|
||||
_Theme.Reflection = null;
|
||||
}
|
||||
|
||||
if (_ThemeLoaded)
|
||||
@@ -198,11 +199,12 @@ namespace VocaluxeLib.Menu
|
||||
_Theme.Color.Get(_PartyModeID, out Color);
|
||||
|
||||
MaxRect = _Theme.Rect;
|
||||
Reflection = _Theme.Reflection.Enabled;
|
||||
Reflection = _Theme.Reflection.HasValue;
|
||||
if (Reflection)
|
||||
{
|
||||
ReflectionSpace = _Theme.Reflection.Space;
|
||||
ReflectionHeight = _Theme.Reflection.Height;
|
||||
Debug.Assert(_Theme.Reflection != null);
|
||||
ReflectionSpace = _Theme.Reflection.Value.Space;
|
||||
ReflectionHeight = _Theme.Reflection.Value.Height;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace VocaluxeLib.Menu
|
||||
[XmlElement("Style")] public EStyle FontStyle;
|
||||
[XmlElement("Font")] public string FontFamily;
|
||||
public string Text;
|
||||
public SReflection Reflection;
|
||||
public SReflection? Reflection;
|
||||
}
|
||||
|
||||
public sealed class CText : CMenuElementBase, IMenuElement, IThemeable, IFontObserver
|
||||
@@ -350,10 +350,10 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Space", ref _ReflectionSpace);
|
||||
_ThemeLoaded &= xmlReader.TryGetFloatValue(item + "/Reflection/Height", ref _ReflectionHeight);
|
||||
_Theme.Reflection = new SReflection(true, _ReflectionHeight, _ReflectionSpace);
|
||||
_Theme.Reflection = new SReflection(_ReflectionHeight, _ReflectionSpace);
|
||||
}
|
||||
else
|
||||
_Theme.Reflection = new SReflection(false, 0f, 0f);
|
||||
_Theme.Reflection = null;
|
||||
|
||||
|
||||
// Set values
|
||||
@@ -449,10 +449,10 @@ namespace VocaluxeLib.Menu
|
||||
_ResizeAlign = _Theme.ResizeAlign;
|
||||
Font = new CFont(_Theme.FontFamily, _Theme.FontStyle, _Theme.FontHeight);
|
||||
|
||||
if (_Theme.Reflection.Enabled)
|
||||
if (_Theme.Reflection.HasValue)
|
||||
{
|
||||
_ReflectionSpace = _Theme.Reflection.Space;
|
||||
_ReflectionHeight = _Theme.Reflection.Height;
|
||||
_ReflectionSpace = _Theme.Reflection.Value.Space;
|
||||
_ReflectionHeight = _Theme.Reflection.Value.Height;
|
||||
}
|
||||
|
||||
Text = _Theme.Text;
|
||||
|
||||
+1
-13
@@ -237,23 +237,11 @@ namespace VocaluxeLib
|
||||
[XmlRoot("Reflection")]
|
||||
public struct SReflection
|
||||
{
|
||||
[XmlAttribute] public bool Enabled;
|
||||
public float Height;
|
||||
public float Space;
|
||||
|
||||
//Needed for serialization
|
||||
public bool HeightSpecified
|
||||
public SReflection(float height, float space)
|
||||
{
|
||||
get { return Enabled; }
|
||||
}
|
||||
public bool SpaceSpecified
|
||||
{
|
||||
get { return Enabled; }
|
||||
}
|
||||
|
||||
public SReflection(bool enabled, float height, float space)
|
||||
{
|
||||
Enabled = enabled;
|
||||
Height = height;
|
||||
Space = space;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user