Add cursors to dump sheets command

This commit is contained in:
Gustas
2025-01-27 16:35:37 +02:00
committed by Matthias Mailänder
parent f5ecb9ad99
commit 6fe039f62e
2 changed files with 16 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ namespace OpenRA.Graphics
}
readonly Dictionary<string, Cursor> cursors = [];
readonly SheetBuilder sheetBuilder;
public readonly SheetBuilder SheetBuilder;
readonly GraphicSettings graphicSettings;
Cursor cursor;
@@ -44,7 +44,7 @@ namespace OpenRA.Graphics
hardwareCursorsDisabled = Game.Settings.Graphics.DisableHardwareCursors;
graphicSettings = Game.Settings.Graphics;
sheetBuilder = new SheetBuilder(SheetType.BGRA, cursorSheetSize);
SheetBuilder = new SheetBuilder(SheetType.BGRA, cursorSheetSize);
// Sort the cursors for better packing onto the sheet.
foreach (var kv in cursorProvider.Cursors
@@ -82,7 +82,7 @@ namespace OpenRA.Graphics
type = SpriteFrameType.Bgra32;
}
c.Sprites[c.Length++] = sheetBuilder.Add(data, type, f.Size, 0, hotspot);
c.Sprites[c.Length++] = SheetBuilder.Add(data, type, f.Size, 0, hotspot);
// Bounds relative to the hotspot
c.Bounds = Rectangle.Union(c.Bounds, new Rectangle(hotspot, f.Size));
@@ -94,8 +94,12 @@ namespace OpenRA.Graphics
cursors.Add(kv.Key, c);
}
CreateOrUpdateHardwareCursors();
Update();
// Allow the utility to create a cursor manager.
if (Game.Renderer != null)
{
CreateOrUpdateHardwareCursors();
Update();
}
}
void CreateOrUpdateHardwareCursors()
@@ -128,7 +132,7 @@ namespace OpenRA.Graphics
}
}
sheetBuilder.Current?.ReleaseBuffer();
SheetBuilder.Current?.ReleaseBuffer();
hardwareCursorsDoubled = graphicSettings.CursorDouble;
}
@@ -293,7 +297,7 @@ namespace OpenRA.Graphics
ClearHardwareCursors();
cursors.Clear();
sheetBuilder.Dispose();
SheetBuilder.Dispose();
}
}
}

View File

@@ -62,6 +62,11 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
var sheetCount = 1;
var cursorProvider = new CursorProvider(modData);
using (var cursor = new CursorManager(cursorProvider, modData.Manifest.CursorSheetSize))
foreach (var sheet in cursor.SheetBuilder.AllSheets)
CommitSheet(null, sheet, "cursors", palette, ref sheetCount);
foreach (var sequence in sequences)
{
sequence.LoadSprites();