mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-17 05:18:27 +00:00
add ability to display all IFP packages in anim window
This commit is contained in:
parent
e2d1702e6b
commit
194c1ceb6d
3 changed files with 61 additions and 17 deletions
Assets/Scripts
|
@ -73,6 +73,21 @@ namespace SanAndreasUnity.Importing.Archive
|
|||
return _sLoadedArchives.Any(x => x.ContainsFile(name));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static void GetFileNamesWithExtension(string ext, List<string> fileNames)
|
||||
{
|
||||
foreach (var archive in _sLoadedArchives)
|
||||
fileNames.AddRange(archive.GetFileNamesWithExtension(ext));
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static List<string> GetFileNamesWithExtension(string ext)
|
||||
{
|
||||
var list = new List<string>();
|
||||
GetFileNamesWithExtension(ext, list);
|
||||
return list;
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.Synchronized)]
|
||||
public static Stream ReadFile(string name)
|
||||
{
|
||||
|
|
|
@ -194,22 +194,26 @@ namespace SanAndreasUnity.Importing.Conversion
|
|||
|
||||
private static readonly Dictionary<string, Package> _sLoaded
|
||||
= new Dictionary<string, Package>();
|
||||
/// All loaded anims. Each entry contains file name and corresponding ifp package.
|
||||
public static IEnumerable<KeyValuePair<string, Package>> Loaded { get { return _sLoaded; } }
|
||||
/// All loaded ifp packages. Each entry contains file name and corresponding ifp package.
|
||||
public static IReadOnlyDictionary<string, Package> Loaded { get { return _sLoaded; } }
|
||||
|
||||
|
||||
public static Package LoadPackageOnly(string fileName)
|
||||
{
|
||||
Package package;
|
||||
|
||||
if (_sLoaded.TryGetValue(fileName, out package))
|
||||
return package;
|
||||
|
||||
package = new Package(fileName);
|
||||
_sLoaded.Add(fileName, package);
|
||||
|
||||
return package;
|
||||
}
|
||||
|
||||
public static Animation Load(string fileName, string clipName, FrameContainer frames)
|
||||
{
|
||||
Package package;
|
||||
if (!_sLoaded.ContainsKey(fileName))
|
||||
{
|
||||
_sLoaded.Add(fileName, package = new Package(fileName));
|
||||
}
|
||||
else
|
||||
{
|
||||
package = _sLoaded[fileName];
|
||||
}
|
||||
|
||||
Package package = LoadPackageOnly(fileName);
|
||||
return package.Load(clipName, frames);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace SanAndreasUnity.UI {
|
|||
private float m_maxScrollViewHeight = 600;
|
||||
private int m_selectedPackageIndex = 0;
|
||||
|
||||
private string[] m_ifpFileNames = new string[] {};
|
||||
|
||||
|
||||
AnimationsWindow() {
|
||||
|
||||
|
@ -35,6 +37,14 @@ namespace SanAndreasUnity.UI {
|
|||
this.windowRect = Utilities.GUIUtils.GetCenteredRect( new Vector2( 500, Screen.height * 0.85f ) );
|
||||
}
|
||||
|
||||
protected override void OnLoaderFinished()
|
||||
{
|
||||
base.OnLoaderFinished();
|
||||
|
||||
// cache all IFPs
|
||||
m_ifpFileNames = Importing.Archive.ArchiveManager.GetFileNamesWithExtension("ifp").ToArray();
|
||||
}
|
||||
|
||||
|
||||
protected override void OnWindowGUI ()
|
||||
{
|
||||
|
@ -178,23 +188,38 @@ namespace SanAndreasUnity.UI {
|
|||
|
||||
void DisplayPackages(bool playerExists)
|
||||
{
|
||||
var packages = Importing.Conversion.Animation.Loaded.ToArray ();
|
||||
if (packages.Length < 1)
|
||||
var packageNames = m_ifpFileNames;
|
||||
if (packageNames.Length < 1)
|
||||
{
|
||||
GUILayout.Label ("There are no loaded ifp packages");
|
||||
GUILayout.Label ("There are no ifp packages");
|
||||
return;
|
||||
}
|
||||
|
||||
float animHeight = 25;
|
||||
|
||||
GUILayout.Label ("Ifp name:");
|
||||
m_selectedPackageIndex = GUILayout.Toolbar(m_selectedPackageIndex, packages.Select(p => p.Key).ToArray());
|
||||
int newPackageIndex = GUILayout.Toolbar(m_selectedPackageIndex, packageNames);
|
||||
|
||||
var package = packages [m_selectedPackageIndex].Value.AnimPackage;
|
||||
if (newPackageIndex != m_selectedPackageIndex)
|
||||
{
|
||||
// changed selected package
|
||||
|
||||
m_selectedPackageIndex = newPackageIndex;
|
||||
|
||||
// load the package if it was not loaded so far
|
||||
bool packageLoaded = Importing.Conversion.Animation.Loaded.ContainsKey(packageNames[newPackageIndex]);
|
||||
if (!packageLoaded)
|
||||
Importing.Conversion.Animation.LoadPackageOnly(packageNames[newPackageIndex]);
|
||||
|
||||
}
|
||||
|
||||
var package = Importing.Conversion.Animation.Loaded[packageNames[m_selectedPackageIndex]].AnimPackage;
|
||||
var clips = package.Clips;
|
||||
|
||||
GUILayout.Space (10);
|
||||
|
||||
// display all clips from this IFP package
|
||||
|
||||
m_scrollViewPos = GUILayout.BeginScrollView (m_scrollViewPos, GUILayout.MinHeight(m_minScrollViewHeight), GUILayout.MaxHeight(m_maxScrollViewHeight));
|
||||
|
||||
for (int i = 0; i < clips.Length; i++)
|
||||
|
|
Loading…
Add table
Reference in a new issue