Using null instead of CTexture(-1) for "no texture"
This commit is contained in:
1 parent
f370693dde
commit
142a690cc6
27 files changed
+430
-588
No files matched your search
@@ -6,11 +6,11 @@ namespace VocaluxeLib.Draw
|
||||
{
|
||||
public class CTexture
|
||||
{
|
||||
public int Index;
|
||||
public int Index = -1;
|
||||
public int PBO;
|
||||
public int ID;
|
||||
public int ID = -1;
|
||||
|
||||
public string TexturePath;
|
||||
public string TexturePath = "";
|
||||
|
||||
/// <summary>
|
||||
/// Original size (e.g. of bmp)
|
||||
@@ -26,10 +26,9 @@ namespace VocaluxeLib.Draw
|
||||
/// </summary>
|
||||
public SRectF Rect;
|
||||
|
||||
public SColorF Color;
|
||||
public SColorF Color = new SColorF(1f, 1f, 1f, 1f);
|
||||
|
||||
private int _W2, _H2;
|
||||
private float _WidthRatio, _HeightRatio;
|
||||
private bool _UseFullTexture;
|
||||
/// <summary>
|
||||
/// Internal texture width (on device), a power of 2 if necessary
|
||||
@@ -61,19 +60,11 @@ namespace VocaluxeLib.Draw
|
||||
/// <summary>
|
||||
/// Internal use. Specifies which part of texture memory is actually used
|
||||
/// </summary>
|
||||
public float WidthRatio
|
||||
{
|
||||
get { return _WidthRatio; }
|
||||
private set { _WidthRatio = value; }
|
||||
}
|
||||
public float WidthRatio { get; private set; }
|
||||
/// <summary>
|
||||
/// Internal use. Specifies which part of texture memory is actually used
|
||||
/// </summary>
|
||||
public float HeightRatio
|
||||
{
|
||||
get { return _HeightRatio; }
|
||||
private set { _HeightRatio = value; }
|
||||
}
|
||||
public float HeightRatio { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Internal use. Specifies if full texture memory should be used
|
||||
@@ -101,20 +92,12 @@ namespace VocaluxeLib.Draw
|
||||
public CTexture(int index, int origWidth = 1, int origHeight = 1)
|
||||
{
|
||||
Index = index;
|
||||
PBO = 0;
|
||||
ID = -1;
|
||||
TexturePath = String.Empty;
|
||||
|
||||
OrigSize = new Size(origWidth, origHeight);
|
||||
Rect = new SRectF(0f, 0f, origWidth, origHeight, 0f);
|
||||
|
||||
Color = new SColorF(1f, 1f, 1f, 1f);
|
||||
|
||||
_W2 = origWidth;
|
||||
_H2 = origHeight;
|
||||
_WidthRatio = 1;
|
||||
_HeightRatio = 1;
|
||||
_UseFullTexture = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -80,8 +80,8 @@ namespace VocaluxeLib.Menu
|
||||
Text.Selected = value;
|
||||
}
|
||||
}
|
||||
public bool Visible;
|
||||
public bool Enabled;
|
||||
public bool Visible = true;
|
||||
public bool Enabled = true;
|
||||
|
||||
public string GetThemeName()
|
||||
{
|
||||
@@ -91,28 +91,10 @@ namespace VocaluxeLib.Menu
|
||||
public CButton(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeButton();
|
||||
Rect = new SRectF();
|
||||
Color = new SColorF();
|
||||
SelColor = new SColorF();
|
||||
Texture = new CTexture(-1);
|
||||
SelTexture = new CTexture(-1);
|
||||
|
||||
_IsSelText = false;
|
||||
Text = new CText(_PartyModeID);
|
||||
_SelText = new CText(_PartyModeID);
|
||||
Selected = false;
|
||||
Visible = true;
|
||||
EditMode = false;
|
||||
Enabled = true;
|
||||
|
||||
_Reflection = false;
|
||||
_ReflectionSpace = 0f;
|
||||
_ReflectionHeight = 0f;
|
||||
|
||||
_SelReflection = false;
|
||||
_SelReflectionSpace = 0f;
|
||||
_SelReflectionHeight = 0f;
|
||||
}
|
||||
|
||||
public CButton(CButton button)
|
||||
@@ -132,13 +114,10 @@ namespace VocaluxeLib.Menu
|
||||
Texture = button.Texture;
|
||||
SelTexture = button.SelTexture;
|
||||
|
||||
_IsSelText = false;
|
||||
Text = new CText(button.Text);
|
||||
_SelText = new CText(button._SelText);
|
||||
Selected = false;
|
||||
Visible = true;
|
||||
EditMode = false;
|
||||
_ThemeLoaded = false;
|
||||
Enabled = button.Enabled;
|
||||
|
||||
_Reflection = button._Reflection;
|
||||
|
||||
@@ -50,7 +50,7 @@ namespace VocaluxeLib.Menu
|
||||
private SRectF _Rect;
|
||||
private float _Size;
|
||||
private SColorF _Color;
|
||||
private float _Alpha;
|
||||
private float _Alpha = 1;
|
||||
private float _Angle; //0..360°
|
||||
private readonly float _MaxAge; //[s]
|
||||
private float _Age; //[s]
|
||||
@@ -62,7 +62,7 @@ namespace VocaluxeLib.Menu
|
||||
private float _LastTime;
|
||||
private readonly EParticleType _Type;
|
||||
|
||||
private readonly Stopwatch _Timer;
|
||||
private readonly Stopwatch _Timer = new Stopwatch();
|
||||
#endregion private vars
|
||||
|
||||
#region public vars
|
||||
@@ -116,21 +116,15 @@ namespace VocaluxeLib.Menu
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_TextureName = textureName;
|
||||
_Texture = new CTexture(-1);
|
||||
_Color = color;
|
||||
_Rect = new SRectF(x, y, size, size, z);
|
||||
_Size = size;
|
||||
_Alpha = 1f;
|
||||
_Angle = 0f;
|
||||
_Vx = vx;
|
||||
_Vy = vy;
|
||||
_Vr = vr;
|
||||
_Vsize = vsize;
|
||||
_LastTime = 0f;
|
||||
_Type = type;
|
||||
|
||||
_Timer = new Stopwatch();
|
||||
_Age = 0f;
|
||||
_MaxAge = maxage;
|
||||
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
|
||||
}
|
||||
@@ -144,17 +138,12 @@ namespace VocaluxeLib.Menu
|
||||
_Color = color;
|
||||
_Rect = new SRectF(x, y, size, size, z);
|
||||
_Size = size;
|
||||
_Alpha = 1f;
|
||||
_Angle = 0f;
|
||||
_Vx = vx;
|
||||
_Vy = vy;
|
||||
_Vr = vr;
|
||||
_Vsize = vsize;
|
||||
_LastTime = 0f;
|
||||
_Type = type;
|
||||
|
||||
_Timer = new Stopwatch();
|
||||
_Age = 0f;
|
||||
_MaxAge = maxage;
|
||||
_Rotation = (float)(CBase.Game.GetRandomDouble() * 360.0);
|
||||
}
|
||||
@@ -357,7 +346,6 @@ namespace VocaluxeLib.Menu
|
||||
Rect = rect;
|
||||
Color = color;
|
||||
_Theme.TextureName = textureName;
|
||||
Texture = new CTexture(-1);
|
||||
_MaxNumber = maxNumber;
|
||||
_Size = size;
|
||||
_Type = type;
|
||||
@@ -603,7 +591,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void UnloadTextures()
|
||||
{
|
||||
Texture = new CTexture();
|
||||
Texture = null;
|
||||
}
|
||||
|
||||
public void LoadTextures()
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void AddValue(string value, int partyModeID)
|
||||
{
|
||||
AddValue(value, new CTexture(-1), _ValueIndexes.Count, partyModeID);
|
||||
AddValue(value, null, _ValueIndexes.Count, partyModeID);
|
||||
}
|
||||
|
||||
public void AddValue(string value, CTexture texture)
|
||||
@@ -560,7 +560,7 @@ namespace VocaluxeLib.Menu
|
||||
public void AddValues(IEnumerable<string> values)
|
||||
{
|
||||
foreach (string value in values)
|
||||
_AddValue(value, new CTexture(-1), _PartyModeID);
|
||||
_AddValue(value, null, _PartyModeID);
|
||||
|
||||
_ValueBounds.Clear();
|
||||
}
|
||||
@@ -589,12 +589,7 @@ namespace VocaluxeLib.Menu
|
||||
RenameValue(Selection, newName);
|
||||
}
|
||||
|
||||
public void RenameValue(int selection, string newName)
|
||||
{
|
||||
RenameValue(selection, newName, new CTexture(-1));
|
||||
}
|
||||
|
||||
public void RenameValue(int selection, string newName, CTexture newTexture)
|
||||
public void RenameValue(int selection, string newName, CTexture newTexture = null)
|
||||
{
|
||||
if (selection < 0 && selection >= _ValueNames.Count)
|
||||
return;
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace VocaluxeLib.Menu
|
||||
private CTexture _Texture;
|
||||
public CTexture Texture
|
||||
{
|
||||
get { return _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); }
|
||||
get { return _Texture?? CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID); }
|
||||
|
||||
set { _Texture = value; }
|
||||
}
|
||||
@@ -59,35 +59,20 @@ namespace VocaluxeLib.Menu
|
||||
public float ReflectionHeight;
|
||||
|
||||
public bool Selected;
|
||||
public bool Visible;
|
||||
public bool Visible=true;
|
||||
|
||||
public float Alpha;
|
||||
public float Alpha=1;
|
||||
|
||||
public EAspect Aspect = EAspect.Stretch;
|
||||
|
||||
public CStatic(int partyModeID)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeStatic();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = new CTexture(-1);
|
||||
Color = new SColorF();
|
||||
Rect = new SRectF();
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
|
||||
Selected = false;
|
||||
Alpha = 1f;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public CStatic(CStatic s)
|
||||
{
|
||||
_PartyModeID = s._PartyModeID;
|
||||
_Theme = new SThemeStatic();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = s.Texture;
|
||||
Color = new SColorF(s.Color);
|
||||
@@ -104,37 +89,18 @@ namespace VocaluxeLib.Menu
|
||||
public CStatic(int partyModeID, CTexture texture, SColorF color, SRectF rect)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeStatic();
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = texture;
|
||||
Color = color;
|
||||
Rect = rect;
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
|
||||
Selected = false;
|
||||
Alpha = 1f;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public CStatic(int partyModeID, string textureSkinName, SColorF color, SRectF rect)
|
||||
{
|
||||
_PartyModeID = partyModeID;
|
||||
_Theme = new SThemeStatic {TextureName = textureSkinName};
|
||||
_ThemeLoaded = false;
|
||||
|
||||
_Texture = new CTexture(-1);
|
||||
_Theme.TextureName = textureSkinName;
|
||||
Color = color;
|
||||
Rect = rect;
|
||||
Reflection = false;
|
||||
ReflectionSpace = 0f;
|
||||
ReflectionHeight = 0f;
|
||||
|
||||
Selected = false;
|
||||
Alpha = 1f;
|
||||
Visible = true;
|
||||
}
|
||||
|
||||
public bool LoadTheme(string xmlPath, string elementName, CXMLReader xmlReader, int skinIndex)
|
||||
@@ -239,7 +205,7 @@ namespace VocaluxeLib.Menu
|
||||
|
||||
public void Draw(float scale, float z, EAspect aspect, bool forceDraw = false)
|
||||
{
|
||||
CTexture texture = _Texture.Index != -1 ? _Texture : CBase.Theme.GetSkinTexture(_Theme.TextureName, _PartyModeID);
|
||||
CTexture texture = Texture;
|
||||
|
||||
SRectF bounds = new SRectF(
|
||||
Rect.X - Rect.W * (scale - 1f),
|
||||
|
||||
@@ -25,9 +25,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
public class CCategory
|
||||
{
|
||||
public readonly string Name;
|
||||
private CTexture _CoverTextureSmall = new CTexture(-1);
|
||||
private CTexture _CoverTextureBig = new CTexture(-1);
|
||||
private bool _CoverBigLoaded;
|
||||
private CTexture _CoverTextureSmall;
|
||||
private CTexture _CoverTextureBig;
|
||||
public readonly List<CSongPointer> Songs = new List<CSongPointer>();
|
||||
|
||||
public CCategory(string name)
|
||||
@@ -44,13 +43,12 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public CTexture CoverTextureBig
|
||||
{
|
||||
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
|
||||
get { return _CoverTextureBig ?? _CoverTextureSmall; }
|
||||
set
|
||||
{
|
||||
if (value.Index == -1)
|
||||
return;
|
||||
_CoverTextureBig = value;
|
||||
_CoverBigLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,8 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public class CSong
|
||||
{
|
||||
private bool _CoverSmallLoaded;
|
||||
private bool _CoverBigLoaded;
|
||||
private CTexture _CoverTextureSmall = new CTexture(-1);
|
||||
private CTexture _CoverTextureBig = new CTexture(-1);
|
||||
private CTexture _CoverTextureSmall;
|
||||
private CTexture _CoverTextureBig;
|
||||
|
||||
public SMedley Medley;
|
||||
|
||||
@@ -101,26 +99,18 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!_CoverSmallLoaded)
|
||||
if (_CoverTextureSmall == null)
|
||||
LoadSmallCover();
|
||||
return _CoverTextureSmall;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
_CoverTextureSmall = value;
|
||||
_CoverSmallLoaded = true;
|
||||
}
|
||||
set { _CoverTextureSmall = value; }
|
||||
}
|
||||
|
||||
public CTexture CoverTextureBig
|
||||
{
|
||||
get { return _CoverBigLoaded ? _CoverTextureBig : _CoverTextureSmall; }
|
||||
set
|
||||
{
|
||||
_CoverTextureBig = value;
|
||||
_CoverBigLoaded = true;
|
||||
}
|
||||
get { return _CoverTextureBig ?? _CoverTextureSmall; }
|
||||
set { _CoverTextureBig = value; }
|
||||
}
|
||||
|
||||
public string Title = String.Empty;
|
||||
@@ -215,8 +205,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
VideoFileName = song.VideoFileName;
|
||||
|
||||
VideoAspect = song.VideoAspect;
|
||||
_CoverSmallLoaded = song._CoverSmallLoaded;
|
||||
_CoverBigLoaded = song._CoverBigLoaded;
|
||||
NotesLoaded = song.NotesLoaded;
|
||||
|
||||
Artist = song.Artist;
|
||||
@@ -751,7 +739,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public void LoadSmallCover()
|
||||
{
|
||||
if (_CoverSmallLoaded)
|
||||
if (_CoverTextureSmall != null)
|
||||
return;
|
||||
if (CoverFileName != "")
|
||||
{
|
||||
@@ -760,8 +748,6 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
else
|
||||
_CoverTextureSmall = CBase.Cover.GetNoCover();
|
||||
|
||||
_CoverSmallLoaded = true;
|
||||
}
|
||||
|
||||
private void _CheckFiles()
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
private readonly List<int> _Streams = new List<int>();
|
||||
private int _Actsong = -1;
|
||||
private int _Actsongstream = -1;
|
||||
protected CTexture _Vidtex = new CTexture(-1);
|
||||
protected CTexture _Vidtex;
|
||||
|
||||
protected bool _Initialized;
|
||||
protected int _LastKnownNumSongs;
|
||||
@@ -464,7 +464,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
public virtual void OnShow()
|
||||
{
|
||||
_Actsongstream = -1;
|
||||
_Vidtex = new CTexture(-1);
|
||||
_Vidtex = null;
|
||||
}
|
||||
|
||||
public virtual void OnHide()
|
||||
|
||||
@@ -453,8 +453,7 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
_TextBG.Draw();
|
||||
|
||||
|
||||
if (_Vidtex.Index != -1 && _Video != -1)
|
||||
if (_Vidtex != null && _Video != -1)
|
||||
{
|
||||
if (_Vidtex.Color.A < 1)
|
||||
_CoverBig.Draw(1f, EAspect.Crop);
|
||||
|
||||
@@ -201,7 +201,7 @@ namespace VocaluxeLib.Menu
|
||||
// ReSharper restore UnusedParameter.Local
|
||||
{
|
||||
FileName = String.Empty;
|
||||
Texture = new CTexture(-1);
|
||||
Texture = null;
|
||||
}
|
||||
}
|
||||
#endregion Profiles
|
||||
|
||||
Reference in new issue
Block a user