Merge branch 'develop' into ScalingFix
This commit is contained in:
29 files changed
+712
-125
No files matched your search
+21
-23
@@ -1,4 +1,4 @@
|
||||
#region license
|
||||
#region license
|
||||
// This file is part of Vocaluxe.
|
||||
//
|
||||
// Vocaluxe is free software: you can redistribute it and/or modify
|
||||
@@ -20,6 +20,7 @@ using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using VocaluxeLib.Log;
|
||||
|
||||
namespace VocaluxeLib
|
||||
@@ -100,6 +101,7 @@ namespace VocaluxeLib
|
||||
|
||||
switch (aspect)
|
||||
{
|
||||
case EAspect.Automatic:
|
||||
case EAspect.Crop:
|
||||
if (boundsAspectRatio >= aspectRatio)
|
||||
{
|
||||
@@ -137,7 +139,12 @@ namespace VocaluxeLib
|
||||
}
|
||||
break;
|
||||
case EAspect.LetterBox:
|
||||
if (boundsAspectRatio <= aspectRatio)
|
||||
if (boundsAspectRatio == aspectRatio) // Pillarbox
|
||||
{
|
||||
scaledWidth = bounds.W * 0.77f;
|
||||
scaledHeight = bounds.W / aspectRatio;
|
||||
}
|
||||
else if (boundsAspectRatio < aspectRatio)
|
||||
{
|
||||
scaledWidth = bounds.W;
|
||||
scaledHeight = bounds.W / aspectRatio;
|
||||
@@ -165,25 +172,20 @@ namespace VocaluxeLib
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
/// <param name="fullpath">False for just file names, True for full path</param>
|
||||
/// <returns>List of file names</returns>
|
||||
public static List<string> ListFiles(string path, string searchPattern, bool recursive = false, bool fullpath = false)
|
||||
public static IEnumerable<string> ListFiles(string path, string searchPattern, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
var files = new List<string>();
|
||||
IEnumerable<string> files = Enumerable.Empty<string>();
|
||||
var dir = new DirectoryInfo(path);
|
||||
if (!dir.Exists)
|
||||
return files;
|
||||
|
||||
if (recursive && !fullpath)
|
||||
throw new NotSupportedException("recursive file listing with relative path names is not supported");
|
||||
|
||||
try
|
||||
{
|
||||
// ReSharper disable LoopCanBeConvertedToQuery
|
||||
foreach (FileInfo file in dir.GetFiles(searchPattern))
|
||||
// ReSharper restore LoopCanBeConvertedToQuery
|
||||
files.Add(!fullpath ? file.Name : file.FullName);
|
||||
|
||||
if (recursive)
|
||||
{
|
||||
foreach (DirectoryInfo di in dir.GetDirectories())
|
||||
files.AddRange(ListFiles(di.FullName, searchPattern, true, fullpath));
|
||||
}
|
||||
files = Directory.EnumerateFiles(dir.FullName, searchPattern, recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
|
||||
files = files.Select(fullpath ? (Func<string, string>)Path.GetFullPath : Path.GetFileName);
|
||||
}
|
||||
catch (Exception) {}
|
||||
|
||||
@@ -198,13 +200,9 @@ namespace VocaluxeLib
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
/// <param name="fullpath">False for just file names, True for full path</param>
|
||||
/// <returns>List of file names</returns>
|
||||
public static List<string> ListFiles(string path, IEnumerable<string> searchPatterns, bool recursive = false, bool fullpath = false)
|
||||
public static IEnumerable<string> ListFiles(string path, IEnumerable<string> searchPatterns, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
var files = new List<string>();
|
||||
foreach (string pattern in searchPatterns)
|
||||
files.AddRange(ListFiles(path, pattern, recursive, fullpath));
|
||||
|
||||
return files;
|
||||
return searchPatterns.SelectMany(pattern => ListFiles(path, pattern, recursive, fullpath));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -214,7 +212,7 @@ namespace VocaluxeLib
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
/// <param name="fullpath">False for just file names, True for full path</param>
|
||||
/// <returns>List of image file names</returns>
|
||||
public static List<string> ListImageFiles(string path, bool recursive = false, bool fullpath = false)
|
||||
public static IEnumerable<string> ListImageFiles(string path, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
return ListFiles(path, _ImageFileTypes, recursive, fullpath);
|
||||
}
|
||||
@@ -226,7 +224,7 @@ namespace VocaluxeLib
|
||||
/// <param name="recursive">Search directories recursively</param>
|
||||
/// <param name="fullpath">False for just file names, True for full path</param>
|
||||
/// <returns>List of image file names</returns>
|
||||
public static List<string> ListSoundFiles(string path, bool recursive = false, bool fullpath = false)
|
||||
public static IEnumerable<string> ListSoundFiles(string path, bool recursive = false, bool fullpath = false)
|
||||
{
|
||||
return ListFiles(path, _SoundFileTypes, recursive, fullpath);
|
||||
}
|
||||
@@ -314,4 +312,4 @@ namespace VocaluxeLib
|
||||
return bmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ namespace VocaluxeLib
|
||||
#region Fonts
|
||||
public enum EAspect
|
||||
{
|
||||
Automatic,
|
||||
Crop,
|
||||
LetterBox,
|
||||
Stretch,
|
||||
@@ -436,4 +437,4 @@ namespace VocaluxeLib
|
||||
TR_USERROLE_PROFILEEDITOR = 32
|
||||
// ReSharper restore InconsistentNaming
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,10 +196,10 @@ namespace VocaluxeLib.Log
|
||||
int i = 0;
|
||||
return theRegex.Replace(template, delegate(Match match)
|
||||
{
|
||||
if (propertyValues.Length >= i)
|
||||
if (i >= propertyValues.Length)
|
||||
return match.Value;
|
||||
return propertyValues[i++].ToString();
|
||||
});
|
||||
return "\"" + propertyValues[i++] + "\"";
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -288,7 +288,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
public void LeaveSelectedCategory()
|
||||
{
|
||||
_LeaveCategory();
|
||||
// Stefan1200: This was implemented with the pull request #359 and is the reason for the bug described in issue #390.
|
||||
// Currently disabled until we know if this is still needed or we find a better solution!
|
||||
// _LeaveCategory();
|
||||
}
|
||||
|
||||
public virtual void UnloadSkin() {}
|
||||
@@ -425,4 +427,4 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
#endregion ThemeEdit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -511,7 +511,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
}
|
||||
_TextBG.Draw();
|
||||
|
||||
CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null;
|
||||
CTextureRef vidtex = null;
|
||||
if (CBase.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON)
|
||||
vidtex = (CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null);
|
||||
|
||||
if (vidtex != null)
|
||||
{
|
||||
@@ -592,13 +594,28 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
private void _UpdateList(bool force = false)
|
||||
{
|
||||
bool isInCategory = CBase.Songs.IsInCategory();
|
||||
int itemCount = isInCategory ? CBase.Songs.GetNumSongsVisible() : CBase.Songs.GetNumCategories();
|
||||
int halfListLength = _ListLength / 2;
|
||||
int offset;
|
||||
|
||||
if (_SelectionNr < _Offset && _SelectionNr >= 0)
|
||||
offset = _SelectionNr;
|
||||
{
|
||||
if (_SelectionNr - halfListLength >= 0)
|
||||
offset = _SelectionNr - halfListLength;
|
||||
else
|
||||
offset = 0;
|
||||
}
|
||||
else if (_SelectionNr >= _Offset + _ListLength)
|
||||
offset = _SelectionNr - _ListLength + 1;
|
||||
{
|
||||
if (_SelectionNr + halfListLength > itemCount)
|
||||
offset = itemCount - _ListLength;
|
||||
else
|
||||
offset = _SelectionNr - halfListLength;
|
||||
}
|
||||
else
|
||||
offset = _Offset;
|
||||
|
||||
_UpdateList(offset, force);
|
||||
}
|
||||
|
||||
@@ -653,4 +670,4 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
base.LoadSkin();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -485,7 +485,9 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
|
||||
_TextBG.Draw();
|
||||
|
||||
CTextureRef vidtex = CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null;
|
||||
CTextureRef vidtex = null;
|
||||
if (CBase.Config.GetVideoPreview() == EOffOn.TR_CONFIG_ON)
|
||||
vidtex = (CBase.BackgroundMusic.IsPlayingPreview() ? CBase.BackgroundMusic.GetVideoTexture() : null);
|
||||
|
||||
if (vidtex != null)
|
||||
{
|
||||
@@ -608,4 +610,4 @@ namespace VocaluxeLib.Menu.SongMenu
|
||||
Init();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,7 @@ namespace VocaluxeLib.Songs
|
||||
public readonly List<string> BackgroundFileNames = new List<string>();
|
||||
public string VideoFileName = String.Empty;
|
||||
|
||||
public EAspect VideoAspect = EAspect.Crop;
|
||||
public EAspect VideoAspect = EAspect.Automatic;
|
||||
|
||||
public bool NotesLoaded { get; private set; }
|
||||
|
||||
@@ -325,7 +325,7 @@ namespace VocaluxeLib.Songs
|
||||
{
|
||||
if (CoverFileName == "")
|
||||
{
|
||||
List<string> files = CHelper.ListImageFiles(Folder);
|
||||
IEnumerable<string> files = CHelper.ListImageFiles(Folder);
|
||||
foreach (String file in files)
|
||||
{
|
||||
if (file.ContainsIgnoreCase("[CO]") &&
|
||||
@@ -336,7 +336,7 @@ namespace VocaluxeLib.Songs
|
||||
|
||||
if (BackgroundFileNames.Count == 0)
|
||||
{
|
||||
List<string> files = CHelper.ListImageFiles(Folder);
|
||||
IEnumerable<string> files = CHelper.ListImageFiles(Folder);
|
||||
foreach (String file in files)
|
||||
{
|
||||
if (file.ContainsIgnoreCase("[BG]") &&
|
||||
@@ -518,4 +518,4 @@ namespace VocaluxeLib.Songs
|
||||
ShortEnd.Source = EDataSource.Calculated;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -110,6 +110,7 @@ namespace VocaluxeLib.Utils.Player
|
||||
|
||||
if (_Video != null || !SongHasVideo)
|
||||
return;
|
||||
|
||||
string videoFilePath = Path.Combine(_Song.Folder, _Song.VideoFileName);
|
||||
_Video = CBase.Video.Load(videoFilePath);
|
||||
if (_Video == null)
|
||||
@@ -175,4 +176,4 @@ namespace VocaluxeLib.Utils.Player
|
||||
_CloseVideo();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user