6
6
using Content . Client . Lobby . UI . Roles ;
7
7
using Content . Client . Message ;
8
8
using Content . Client . Players . PlayTimeTracking ;
9
+ using Content . Client . Sprite ;
9
10
using Content . Client . Stylesheets ;
10
11
using Content . Client . UserInterface . Systems . Guidebook ;
11
12
using Content . Shared . _Sunrise . SunriseCCVars ;
28
29
using Robust . Client . UserInterface . XAML ;
29
30
using Robust . Client . Utility ;
30
31
using Robust . Shared . Configuration ;
32
+ using Robust . Shared . ContentPack ;
31
33
using Robust . Shared . Enums ;
32
34
using Robust . Shared . Prototypes ;
33
35
using Robust . Shared . Utility ;
@@ -45,6 +47,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
45
47
private readonly IFileDialogManager _dialogManager ;
46
48
private readonly IPlayerManager _playerManager ;
47
49
private readonly IPrototypeManager _prototypeManager ;
50
+ private readonly IResourceManager _resManager ;
48
51
private readonly MarkingManager _markingManager ;
49
52
private readonly JobRequirementsManager _requirements ;
50
53
private readonly LobbyUIController _controller ;
@@ -56,6 +59,7 @@ public sealed partial class HumanoidProfileEditor : BoxContainer
56
59
private LoadoutWindow ? _loadoutWindow ;
57
60
58
61
private bool _exporting ;
62
+ private bool _imaging ;
59
63
60
64
/// <summary>
61
65
/// If we're attempting to save.
@@ -111,6 +115,7 @@ public HumanoidProfileEditor(
111
115
ILogManager logManager ,
112
116
IPlayerManager playerManager ,
113
117
IPrototypeManager prototypeManager ,
118
+ IResourceManager resManager ,
114
119
JobRequirementsManager requirements ,
115
120
MarkingManager markings )
116
121
{
@@ -124,6 +129,7 @@ public HumanoidProfileEditor(
124
129
_prototypeManager = prototypeManager ;
125
130
_markingManager = markings ;
126
131
_preferencesManager = preferencesManager ;
132
+ _resManager = resManager ;
127
133
_requirements = requirements ;
128
134
_controller = UserInterfaceManager . GetUIController < LobbyUIController > ( ) ;
129
135
@@ -137,6 +143,16 @@ public HumanoidProfileEditor(
137
143
ExportProfile ( ) ;
138
144
} ;
139
145
146
+ ExportImageButton . OnPressed += args =>
147
+ {
148
+ ExportImage ( ) ;
149
+ } ;
150
+
151
+ OpenImagesButton . OnPressed += args =>
152
+ {
153
+ _resManager . UserData . OpenOsWindow ( ContentSpriteSystem . Exports ) ;
154
+ } ;
155
+
140
156
ResetButton . OnPressed += args =>
141
157
{
142
158
SetProfile ( ( HumanoidCharacterProfile ? ) _preferencesManager . Preferences ? . SelectedCharacter , _preferencesManager . Preferences ? . SelectedCharacterIndex ) ;
@@ -441,7 +457,6 @@ public HumanoidProfileEditor(
441
457
SpeciesInfoButton . OnPressed += OnSpeciesInfoButtonPressed ;
442
458
443
459
UpdateSpeciesGuidebookIcon ( ) ;
444
- ReloadPreview ( ) ;
445
460
IsDirty = false ;
446
461
}
447
462
@@ -728,11 +743,12 @@ private void ReloadPreview()
728
743
_entManager . DeleteEntity ( PreviewDummy ) ;
729
744
PreviewDummy = EntityUid . Invalid ;
730
745
731
- if ( Profile == null || ! _prototypeManager . HasIndex < SpeciesPrototype > ( Profile . Species ) )
746
+ if ( Profile == null || ! _prototypeManager . HasIndex ( Profile . Species ) )
732
747
return ;
733
748
734
749
PreviewDummy = _controller . LoadProfileEntity ( Profile , JobOverride , ShowClothes . Pressed ) ;
735
750
SpriteView . SetEntity ( PreviewDummy ) ;
751
+ _entManager . System < MetaDataSystem > ( ) . SetEntityName ( PreviewDummy , Profile . Name ) ;
736
752
}
737
753
738
754
/// <summary>
@@ -1167,6 +1183,17 @@ protected override void Dispose(bool disposing)
1167
1183
1168
1184
_loadoutWindow ? . Dispose ( ) ;
1169
1185
_loadoutWindow = null ;
1186
+ }
1187
+
1188
+ protected override void EnteredTree ( )
1189
+ {
1190
+ base . EnteredTree ( ) ;
1191
+ ReloadPreview ( ) ;
1192
+ }
1193
+
1194
+ protected override void ExitedTree ( )
1195
+ {
1196
+ base . ExitedTree ( ) ;
1170
1197
_entManager . DeleteEntity ( PreviewDummy ) ;
1171
1198
PreviewDummy = EntityUid . Invalid ;
1172
1199
}
@@ -1237,6 +1264,11 @@ private void SetName(string newName)
1237
1264
{
1238
1265
Profile = Profile ? . WithName ( newName ) ;
1239
1266
SetDirty ( ) ;
1267
+
1268
+ if ( ! IsDirty )
1269
+ return ;
1270
+
1271
+ _entManager . System < MetaDataSystem > ( ) . SetEntityName ( PreviewDummy , newName ) ;
1240
1272
}
1241
1273
1242
1274
private void SetSpawnPriority ( SpawnPriorityPreference newSpawnPriority )
@@ -1587,6 +1619,19 @@ private void RandomizeName()
1587
1619
UpdateNameEdit ( ) ;
1588
1620
}
1589
1621
1622
+ private async void ExportImage ( )
1623
+ {
1624
+ if ( _imaging )
1625
+ return ;
1626
+
1627
+ var dir = SpriteView . OverrideDirection ?? Direction . South ;
1628
+
1629
+ // I tried disabling the button but it looks sorta goofy as it only takes a frame or two to save
1630
+ _imaging = true ;
1631
+ await _entManager . System < ContentSpriteSystem > ( ) . Export ( PreviewDummy , dir , includeId : false ) ;
1632
+ _imaging = false ;
1633
+ }
1634
+
1590
1635
private async void ImportProfile ( )
1591
1636
{
1592
1637
if ( _exporting || CharacterSlot == null || Profile == null )
0 commit comments