-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFortUtils.cs
72 lines (66 loc) · 2.58 KB
/
FortUtils.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
using CUE4Parse.FileProvider;
using CUE4Parse.FN.Exports.FortniteGame;
using CUE4Parse.UE4.Assets;
using System;
using System.Collections.Generic;
using System.IO;
using TModel.Export.Exporters;
using TModel.Exporters;
using TModel.Modules;
namespace TModel
{
// Holds static exporters
public static class FortUtils
{
public static CharacterExporter characterExporter { get; } = new CharacterExporter();
public static BackpackExporter backpackExporter { get; } = new BackpackExporter();
public static GliderExporter gliderExporter { get; } = new GliderExporter();
public static PickaxeExporter pickaxeExporter { get; } = new PickaxeExporter();
public static WeaponExporter weaponExporter { get; } = new WeaponExporter();
public static PropExporter propExporter { get; } = new PropExporter();
public static PlaysetExporter PlaysetExporter { get; } = new PlaysetExporter();
public static Dictionary<GameItemType, ExporterBase> Exporters { get; } = new()
{
[GameItemType.Character] = characterExporter,
[GameItemType.Backpack] = backpackExporter,
[GameItemType.Glider] = gliderExporter,
[GameItemType.Pickaxe] = pickaxeExporter,
[GameItemType.Weapon] = weaponExporter,
[GameItemType.Prop] = propExporter,
[GameItemType.Playset] = PlaysetExporter,
};
// Gets all paths that could be a possible valid export (using the SearchTerm) for the given exporter
public static IEnumerable<GameContentItemPreview> GetGameFiles(ExporterBase exporter)
{
foreach (var path in App.FileProvider.Files)
if (exporter.SearchTerm.CheckName(path.Key))
yield return new GameContentItemPreview() { File = path.Value };
}
public static bool TryLoadItemPreviewInfo(ExporterBase exporter, GameFile gameFile, out ItemTileInfo itemPreviewInfo)
{
itemPreviewInfo = null;
if (App.FileProvider.TryLoadPackage(gameFile, out IPackage package))
{
itemPreviewInfo = exporter.GetTileInfo(package);
if (itemPreviewInfo != null)
itemPreviewInfo.Package = package;
}
return itemPreviewInfo != null;
}
}
public class FortGameContentItem
{
public ItemTileInfo? Info;
public GameFile File;
}
public enum GameItemType
{
Character,
Backpack,
Glider,
Pickaxe,
Weapon,
Prop,
Playset
}
}