Add sprite exporting (#29874)
* Redo of code * Dump IDs on lobby exports
This commit is contained in:
@@ -6,6 +6,7 @@ using Content.Client.Lobby.UI.Loadouts;
|
||||
using Content.Client.Lobby.UI.Roles;
|
||||
using Content.Client.Message;
|
||||
using Content.Client.Players.PlayTimeTracking;
|
||||
using Content.Client.Sprite;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Client.UserInterface.Systems.Guidebook;
|
||||
using Content.Shared.CCVar;
|
||||
@@ -27,6 +28,7 @@ using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.Enums;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -43,6 +45,7 @@ namespace Content.Client.Lobby.UI
|
||||
private readonly IFileDialogManager _dialogManager;
|
||||
private readonly IPlayerManager _playerManager;
|
||||
private readonly IPrototypeManager _prototypeManager;
|
||||
private readonly IResourceManager _resManager;
|
||||
private readonly MarkingManager _markingManager;
|
||||
private readonly JobRequirementsManager _requirements;
|
||||
private readonly LobbyUIController _controller;
|
||||
@@ -54,6 +57,7 @@ namespace Content.Client.Lobby.UI
|
||||
private LoadoutWindow? _loadoutWindow;
|
||||
|
||||
private bool _exporting;
|
||||
private bool _imaging;
|
||||
|
||||
/// <summary>
|
||||
/// If we're attempting to save.
|
||||
@@ -107,6 +111,7 @@ namespace Content.Client.Lobby.UI
|
||||
ILogManager logManager,
|
||||
IPlayerManager playerManager,
|
||||
IPrototypeManager prototypeManager,
|
||||
IResourceManager resManager,
|
||||
JobRequirementsManager requirements,
|
||||
MarkingManager markings)
|
||||
{
|
||||
@@ -119,6 +124,7 @@ namespace Content.Client.Lobby.UI
|
||||
_prototypeManager = prototypeManager;
|
||||
_markingManager = markings;
|
||||
_preferencesManager = preferencesManager;
|
||||
_resManager = resManager;
|
||||
_requirements = requirements;
|
||||
_controller = UserInterfaceManager.GetUIController<LobbyUIController>();
|
||||
|
||||
@@ -132,6 +138,16 @@ namespace Content.Client.Lobby.UI
|
||||
ExportProfile();
|
||||
};
|
||||
|
||||
ExportImageButton.OnPressed += args =>
|
||||
{
|
||||
ExportImage();
|
||||
};
|
||||
|
||||
OpenImagesButton.OnPressed += args =>
|
||||
{
|
||||
_resManager.UserData.OpenOsWindow(ContentSpriteSystem.Exports);
|
||||
};
|
||||
|
||||
ResetButton.OnPressed += args =>
|
||||
{
|
||||
SetProfile((HumanoidCharacterProfile?) _preferencesManager.Preferences?.SelectedCharacter, _preferencesManager.Preferences?.SelectedCharacterIndex);
|
||||
@@ -424,7 +440,6 @@ namespace Content.Client.Lobby.UI
|
||||
SpeciesInfoButton.OnPressed += OnSpeciesInfoButtonPressed;
|
||||
|
||||
UpdateSpeciesGuidebookIcon();
|
||||
ReloadPreview();
|
||||
IsDirty = false;
|
||||
}
|
||||
|
||||
@@ -697,11 +712,12 @@ namespace Content.Client.Lobby.UI
|
||||
_entManager.DeleteEntity(PreviewDummy);
|
||||
PreviewDummy = EntityUid.Invalid;
|
||||
|
||||
if (Profile == null || !_prototypeManager.HasIndex<SpeciesPrototype>(Profile.Species))
|
||||
if (Profile == null || !_prototypeManager.HasIndex(Profile.Species))
|
||||
return;
|
||||
|
||||
PreviewDummy = _controller.LoadProfileEntity(Profile, JobOverride, ShowClothes.Pressed);
|
||||
SpriteView.SetEntity(PreviewDummy);
|
||||
_entManager.System<MetaDataSystem>().SetEntityName(PreviewDummy, Profile.Name);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1122,6 +1138,17 @@ namespace Content.Client.Lobby.UI
|
||||
|
||||
_loadoutWindow?.Dispose();
|
||||
_loadoutWindow = null;
|
||||
}
|
||||
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
base.EnteredTree();
|
||||
ReloadPreview();
|
||||
}
|
||||
|
||||
protected override void ExitedTree()
|
||||
{
|
||||
base.ExitedTree();
|
||||
_entManager.DeleteEntity(PreviewDummy);
|
||||
PreviewDummy = EntityUid.Invalid;
|
||||
}
|
||||
@@ -1182,6 +1209,11 @@ namespace Content.Client.Lobby.UI
|
||||
{
|
||||
Profile = Profile?.WithName(newName);
|
||||
SetDirty();
|
||||
|
||||
if (!IsDirty)
|
||||
return;
|
||||
|
||||
_entManager.System<MetaDataSystem>().SetEntityName(PreviewDummy, newName);
|
||||
}
|
||||
|
||||
private void SetSpawnPriority(SpawnPriorityPreference newSpawnPriority)
|
||||
@@ -1513,6 +1545,19 @@ namespace Content.Client.Lobby.UI
|
||||
UpdateNameEdit();
|
||||
}
|
||||
|
||||
private async void ExportImage()
|
||||
{
|
||||
if (_imaging)
|
||||
return;
|
||||
|
||||
var dir = SpriteView.OverrideDirection ?? Direction.South;
|
||||
|
||||
// I tried disabling the button but it looks sorta goofy as it only takes a frame or two to save
|
||||
_imaging = true;
|
||||
await _entManager.System<ContentSpriteSystem>().Export(PreviewDummy, dir, includeId: false);
|
||||
_imaging = false;
|
||||
}
|
||||
|
||||
private async void ImportProfile()
|
||||
{
|
||||
if (_exporting || CharacterSlot == null || Profile == null)
|
||||
|
||||
Reference in New Issue
Block a user