Fix bug with avatar not having filename

Use a nicer name for the avatar chooser
This commit is contained in:
Flamefire committed 2014-04-09 18:41:39 +02:00
1 parent 0a59b250d3
commit 6686c15864
2 files changed
+16 -8

No files matched your search

+1 -1
View File
@@ -449,7 +449,7 @@ namespace Vocaluxe.Screens
foreach (CAvatar avatar in avatars)
{
_SelectSlides[_SelectSlideAvatars].AddValue(
Path.GetFileName(avatar.FileName),
avatar.GetDisplayName(),
null,
avatar.ID,
-1);
+15 -7
View File
@@ -15,6 +15,8 @@
// along with Vocaluxe. If not, see <http://www.gnu.org/licenses/>.
#endregion
using System.Diagnostics;
using System.IO;
using VocaluxeLib.Draw;
namespace VocaluxeLib.Profile
@@ -22,8 +24,9 @@ namespace VocaluxeLib.Profile
public class CAvatar
{
public int ID;
private string _FileName = "";
private readonly string _FileName = "";
private CTexture _Texture;
private const int _MaxNameLen = 12;
public CTexture Texture
{
@@ -42,13 +45,9 @@ namespace VocaluxeLib.Profile
private CAvatar(CTexture texture, string fileName, int id = -1)
{
ID = id;
}
public bool LoadFromFile(string fileName)
{
_Texture = texture;
_FileName = fileName;
return Reload();
ID = id;
}
public bool Reload()
@@ -63,5 +62,14 @@ namespace VocaluxeLib.Profile
{
CBase.Drawing.RemoveTexture(ref _Texture);
}
public string GetDisplayName()
{
string name = Path.GetFileNameWithoutExtension(_FileName);
Debug.Assert(name != null);
if (name.Length > _MaxNameLen)
name = name.Substring(0, _MaxNameLen);
return name;
}
}
}