Rotating character preview & lobby preview change (#19741)
This commit is contained in:
@@ -43,10 +43,15 @@ namespace Content.Client.Lobby.UI
|
|||||||
CharacterSetupButton = new Button
|
CharacterSetupButton = new Button
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("lobby-character-preview-panel-character-setup-button"),
|
Text = Loc.GetString("lobby-character-preview-panel-character-setup-button"),
|
||||||
HorizontalAlignment = HAlignment.Left
|
HorizontalAlignment = HAlignment.Center,
|
||||||
|
Margin = new Thickness(0, 5, 0, 0),
|
||||||
};
|
};
|
||||||
|
|
||||||
_summaryLabel = new Label();
|
_summaryLabel = new Label
|
||||||
|
{
|
||||||
|
HorizontalAlignment = HAlignment.Center,
|
||||||
|
Margin = new Thickness(3, 3),
|
||||||
|
};
|
||||||
|
|
||||||
var vBox = new BoxContainer
|
var vBox = new BoxContainer
|
||||||
{
|
{
|
||||||
@@ -61,7 +66,8 @@ namespace Content.Client.Lobby.UI
|
|||||||
};
|
};
|
||||||
_viewBox = new BoxContainer
|
_viewBox = new BoxContainer
|
||||||
{
|
{
|
||||||
Orientation = LayoutOrientation.Horizontal
|
Orientation = LayoutOrientation.Horizontal,
|
||||||
|
HorizontalAlignment = HAlignment.Center,
|
||||||
};
|
};
|
||||||
var _vSpacer = new VSpacer();
|
var _vSpacer = new VSpacer();
|
||||||
|
|
||||||
@@ -89,18 +95,6 @@ namespace Content.Client.Lobby.UI
|
|||||||
_previewDummy = default;
|
_previewDummy = default;
|
||||||
}
|
}
|
||||||
|
|
||||||
private SpriteView MakeSpriteView(EntityUid entity, Direction direction)
|
|
||||||
{
|
|
||||||
var spriteView = new SpriteView
|
|
||||||
{
|
|
||||||
OverrideDirection = direction,
|
|
||||||
Scale = new Vector2(2, 2),
|
|
||||||
};
|
|
||||||
|
|
||||||
spriteView.SetEntity(entity);
|
|
||||||
return spriteView;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdateUI()
|
public void UpdateUI()
|
||||||
{
|
{
|
||||||
if (!_preferencesManager.ServerDataLoaded)
|
if (!_preferencesManager.ServerDataLoaded)
|
||||||
@@ -119,15 +113,16 @@ namespace Content.Client.Lobby.UI
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
_previewDummy = _entityManager.SpawnEntity(_prototypeManager.Index<SpeciesPrototype>(selectedCharacter.Species).DollPrototype, MapCoordinates.Nullspace);
|
_previewDummy = _entityManager.SpawnEntity(_prototypeManager.Index<SpeciesPrototype>(selectedCharacter.Species).DollPrototype, MapCoordinates.Nullspace);
|
||||||
var viewSouth = MakeSpriteView(_previewDummy.Value, Direction.South);
|
|
||||||
var viewNorth = MakeSpriteView(_previewDummy.Value, Direction.North);
|
|
||||||
var viewWest = MakeSpriteView(_previewDummy.Value, Direction.West);
|
|
||||||
var viewEast = MakeSpriteView(_previewDummy.Value, Direction.East);
|
|
||||||
_viewBox.DisposeAllChildren();
|
_viewBox.DisposeAllChildren();
|
||||||
_viewBox.AddChild(viewSouth);
|
var spriteView = new SpriteView
|
||||||
_viewBox.AddChild(viewNorth);
|
{
|
||||||
_viewBox.AddChild(viewWest);
|
OverrideDirection = Direction.South,
|
||||||
_viewBox.AddChild(viewEast);
|
Scale = new Vector2(4f, 4f),
|
||||||
|
MaxSize = new Vector2(112, 112),
|
||||||
|
Stretch = SpriteView.StretchMode.None,
|
||||||
|
};
|
||||||
|
spriteView.SetEntity(_previewDummy.Value);
|
||||||
|
_viewBox.AddChild(spriteView);
|
||||||
_summaryLabel.Text = selectedCharacter.Summary;
|
_summaryLabel.Text = selectedCharacter.Summary;
|
||||||
_entityManager.System<HumanoidAppearanceSystem>().LoadProfile(_previewDummy.Value, selectedCharacter);
|
_entityManager.System<HumanoidAppearanceSystem>().LoadProfile(_previewDummy.Value, selectedCharacter);
|
||||||
GiveDummyJobClothes(_previewDummy.Value, selectedCharacter);
|
GiveDummyJobClothes(_previewDummy.Value, selectedCharacter);
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
<Control xmlns="https://spacestation14.io"
|
<Control xmlns="https://spacestation14.io"
|
||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:prefUi="clr-namespace:Content.Client.Preferences.UI"
|
xmlns:prefUi="clr-namespace:Content.Client.Preferences.UI"
|
||||||
xmlns:humanoid="clr-namespace:Content.Client.Humanoid">
|
xmlns:humanoid="clr-namespace:Content.Client.Humanoid"
|
||||||
|
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls">
|
||||||
<BoxContainer Orientation="Horizontal">
|
<BoxContainer Orientation="Horizontal">
|
||||||
<!-- Left side -->
|
<!-- Left side -->
|
||||||
<BoxContainer Orientation="Vertical" Margin="10 10 10 10">
|
<BoxContainer Orientation="Vertical" Margin="10 10 10 10">
|
||||||
@@ -143,9 +144,13 @@
|
|||||||
</TabContainer>
|
</TabContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<!-- Right side -->
|
<!-- Right side -->
|
||||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True">
|
<BoxContainer Orientation="Vertical" VerticalExpand="True" HorizontalExpand="True" VerticalAlignment="Center">
|
||||||
<Control Name="CSpriteViewFront" VerticalExpand="True" SizeFlagsStretchRatio="1" />
|
<SpriteView Name="CSpriteView" Scale="8 8" SizeFlagsStretchRatio="1" />
|
||||||
<Control Name="CSpriteViewSide" VerticalExpand="True" SizeFlagsStretchRatio="1" />
|
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Center" Margin="0 5">
|
||||||
|
<Button Name="CSpriteRotateLeft" Text="◀" StyleClasses="OpenRight" />
|
||||||
|
<cc:VSeparator Margin="2 0 3 0" />
|
||||||
|
<Button Name="CSpriteRotateRight" Text="▶" StyleClasses="OpenLeft" />
|
||||||
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
@@ -88,18 +88,12 @@ namespace Content.Client.Preferences.UI
|
|||||||
private readonly List<AntagPreferenceSelector> _antagPreferences;
|
private readonly List<AntagPreferenceSelector> _antagPreferences;
|
||||||
private readonly List<TraitPreferenceSelector> _traitPreferences;
|
private readonly List<TraitPreferenceSelector> _traitPreferences;
|
||||||
|
|
||||||
private Control _previewSpriteControl => CSpriteViewFront;
|
private SpriteView _previewSpriteView => CSpriteView;
|
||||||
private Control _previewSpriteSideControl => CSpriteViewSide;
|
private Button _previewRotateLeftButton => CSpriteRotateLeft;
|
||||||
|
private Button _previewRotateRightButton => CSpriteRotateRight;
|
||||||
|
private Direction _previewRotation = Direction.North;
|
||||||
private EntityUid? _previewDummy;
|
private EntityUid? _previewDummy;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Used to avoid unnecessarily re-creating the entity.
|
|
||||||
/// </summary>
|
|
||||||
private string? _lastSpecies;
|
|
||||||
private SpriteView? _previewSprite;
|
|
||||||
private SpriteView? _previewSpriteSide;
|
|
||||||
|
|
||||||
private BoxContainer _rgbSkinColorContainer => CRgbSkinColorContainer;
|
private BoxContainer _rgbSkinColorContainer => CRgbSkinColorContainer;
|
||||||
private ColorSelectorSliders _rgbSkinColorSelector;
|
private ColorSelectorSliders _rgbSkinColorSelector;
|
||||||
|
|
||||||
@@ -479,6 +473,18 @@ namespace Content.Client.Preferences.UI
|
|||||||
#endregion FlavorText
|
#endregion FlavorText
|
||||||
|
|
||||||
#region Dummy
|
#region Dummy
|
||||||
|
|
||||||
|
_previewRotateLeftButton.OnPressed += _ =>
|
||||||
|
{
|
||||||
|
_previewRotation = _previewRotation.TurnCw();
|
||||||
|
_needUpdatePreview = true;
|
||||||
|
};
|
||||||
|
_previewRotateRightButton.OnPressed += _ =>
|
||||||
|
{
|
||||||
|
_previewRotation = _previewRotation.TurnCcw();
|
||||||
|
_needUpdatePreview = true;
|
||||||
|
};
|
||||||
|
|
||||||
var species = Profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies;
|
var species = Profile?.Species ?? SharedHumanoidAppearanceSystem.DefaultSpecies;
|
||||||
var dollProto = _prototypeManager.Index<SpeciesPrototype>(species).DollPrototype;
|
var dollProto = _prototypeManager.Index<SpeciesPrototype>(species).DollPrototype;
|
||||||
|
|
||||||
@@ -486,27 +492,7 @@ namespace Content.Client.Preferences.UI
|
|||||||
_entMan.DeleteEntity(_previewDummy!.Value);
|
_entMan.DeleteEntity(_previewDummy!.Value);
|
||||||
|
|
||||||
_previewDummy = _entMan.SpawnEntity(dollProto, MapCoordinates.Nullspace);
|
_previewDummy = _entMan.SpawnEntity(dollProto, MapCoordinates.Nullspace);
|
||||||
_lastSpecies = species;
|
_previewSpriteView.SetEntity(_previewDummy);
|
||||||
|
|
||||||
_previewSprite = new SpriteView
|
|
||||||
{
|
|
||||||
Scale = new Vector2(6, 6),
|
|
||||||
OverrideDirection = Direction.South,
|
|
||||||
VerticalAlignment = VAlignment.Center,
|
|
||||||
SizeFlagsStretchRatio = 1
|
|
||||||
};
|
|
||||||
_previewSprite.SetEntity(_previewDummy.Value);
|
|
||||||
_previewSpriteControl.AddChild(_previewSprite);
|
|
||||||
|
|
||||||
_previewSpriteSide = new SpriteView
|
|
||||||
{
|
|
||||||
Scale = new Vector2(6, 6),
|
|
||||||
OverrideDirection = Direction.East,
|
|
||||||
VerticalAlignment = VAlignment.Center,
|
|
||||||
SizeFlagsStretchRatio = 1
|
|
||||||
};
|
|
||||||
_previewSpriteSide.SetEntity(_previewDummy.Value);
|
|
||||||
_previewSpriteSideControl.AddChild(_previewSpriteSide);
|
|
||||||
#endregion Dummy
|
#endregion Dummy
|
||||||
|
|
||||||
#endregion Left
|
#endregion Left
|
||||||
@@ -726,35 +712,7 @@ namespace Content.Client.Preferences.UI
|
|||||||
_entMan.DeleteEntity(_previewDummy!.Value);
|
_entMan.DeleteEntity(_previewDummy!.Value);
|
||||||
|
|
||||||
_previewDummy = _entMan.SpawnEntity(dollProto, MapCoordinates.Nullspace);
|
_previewDummy = _entMan.SpawnEntity(dollProto, MapCoordinates.Nullspace);
|
||||||
_lastSpecies = species;
|
_previewSpriteView.SetEntity(_previewDummy);
|
||||||
|
|
||||||
if (_previewSprite == null)
|
|
||||||
{
|
|
||||||
// Front
|
|
||||||
_previewSprite = new SpriteView
|
|
||||||
{
|
|
||||||
Scale = new Vector2(6, 6),
|
|
||||||
OverrideDirection = Direction.South,
|
|
||||||
VerticalAlignment = VAlignment.Center,
|
|
||||||
SizeFlagsStretchRatio = 1
|
|
||||||
};
|
|
||||||
_previewSpriteControl.AddChild(_previewSprite);
|
|
||||||
}
|
|
||||||
_previewSprite.SetEntity(_previewDummy.Value);
|
|
||||||
|
|
||||||
if (_previewSpriteSide == null)
|
|
||||||
{
|
|
||||||
_previewSpriteSide = new SpriteView
|
|
||||||
{
|
|
||||||
Scale = new Vector2(6, 6),
|
|
||||||
OverrideDirection = Direction.East,
|
|
||||||
VerticalAlignment = VAlignment.Center,
|
|
||||||
SizeFlagsStretchRatio = 1
|
|
||||||
};
|
|
||||||
_previewSpriteSideControl.AddChild(_previewSpriteSide);
|
|
||||||
}
|
|
||||||
_previewSpriteSide.SetEntity(_previewDummy.Value);
|
|
||||||
|
|
||||||
_needUpdatePreview = true;
|
_needUpdatePreview = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1127,6 +1085,8 @@ namespace Content.Client.Preferences.UI
|
|||||||
|
|
||||||
if (ShowClothes.Pressed)
|
if (ShowClothes.Pressed)
|
||||||
LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy!.Value, Profile);
|
LobbyCharacterPreviewPanel.GiveDummyJobClothes(_previewDummy!.Value, Profile);
|
||||||
|
|
||||||
|
_previewSpriteView.OverrideDirection = (Direction) ((int) _previewRotation % 4 * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateControls()
|
public void UpdateControls()
|
||||||
@@ -1162,7 +1122,6 @@ namespace Content.Client.Preferences.UI
|
|||||||
if (_needUpdatePreview)
|
if (_needUpdatePreview)
|
||||||
{
|
{
|
||||||
UpdatePreview();
|
UpdatePreview();
|
||||||
|
|
||||||
_needUpdatePreview = false;
|
_needUpdatePreview = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user