Remove asset browser dependency on sequences.
This commit is contained in:
@@ -17,6 +17,7 @@ using System.Linq;
|
|||||||
using OpenRA.FileSystem;
|
using OpenRA.FileSystem;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Mods.Common.Traits;
|
using OpenRA.Mods.Common.Traits;
|
||||||
|
using OpenRA.Primitives;
|
||||||
using OpenRA.Video;
|
using OpenRA.Video;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
@@ -57,6 +58,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
readonly ScrollPanelWidget assetList;
|
readonly ScrollPanelWidget assetList;
|
||||||
readonly ScrollItemWidget template;
|
readonly ScrollItemWidget template;
|
||||||
|
|
||||||
|
readonly Cache<SheetType, SheetBuilder> sheetBuilders;
|
||||||
|
readonly Cache<string, Sprite[]> spriteCache;
|
||||||
|
|
||||||
IReadOnlyPackage assetSource = null;
|
IReadOnlyPackage assetSource = null;
|
||||||
bool animateFrames = false;
|
bool animateFrames = false;
|
||||||
|
|
||||||
@@ -82,6 +86,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
[ObjectCreator.UseCtor]
|
[ObjectCreator.UseCtor]
|
||||||
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, WorldRenderer worldRenderer)
|
public AssetBrowserLogic(Widget widget, Action onExit, ModData modData, WorldRenderer worldRenderer)
|
||||||
{
|
{
|
||||||
|
sheetBuilders = new Cache<SheetType, SheetBuilder>(t => new SheetBuilder(t));
|
||||||
|
spriteCache = new Cache<string, Sprite[]>(
|
||||||
|
filename => FrameLoader.GetFrames(modData.DefaultFileSystem, filename, modData.SpriteLoaders, out _)
|
||||||
|
.Select(f => sheetBuilders[SheetBuilder.FrameTypeToSheetType(f.Type)].Add(f))
|
||||||
|
.ToArray());
|
||||||
|
|
||||||
world = worldRenderer.World;
|
world = worldRenderer.World;
|
||||||
this.modData = modData;
|
this.modData = modData;
|
||||||
panel = widget;
|
panel = widget;
|
||||||
@@ -505,7 +515,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
var fileExtension = Path.GetExtension(filename.ToLowerInvariant());
|
var fileExtension = Path.GetExtension(filename.ToLowerInvariant());
|
||||||
if (allowedSpriteExtensions.Contains(fileExtension))
|
if (allowedSpriteExtensions.Contains(fileExtension))
|
||||||
{
|
{
|
||||||
currentSprites = world.Map.Sequences.SpriteCache[prefix + filename];
|
currentSprites = spriteCache[filename];
|
||||||
currentFrame = 0;
|
currentFrame = 0;
|
||||||
|
|
||||||
if (frameSlider != null && currentSprites?.Length > 0)
|
if (frameSlider != null && currentSprites?.Length > 0)
|
||||||
|
|||||||
Reference in New Issue
Block a user