Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 02 28 loadouts #8

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion Content.Client/Lobby/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using Content.Shared.Preferences.Loadouts;
using Content.Shared.Preferences.Loadouts.Effects;
using Content.Shared.Roles;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Robust.Shared.Map;
Expand All @@ -21,6 +22,7 @@ namespace Content.Client.Lobby;
public sealed class LobbyUIController : UIController, IOnStateEntered<LobbyState>, IOnStateExited<LobbyState>
{
[Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
[UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!;
[UISystemDependency] private readonly ClientInventorySystem _inventory = default!;
Expand Down Expand Up @@ -73,14 +75,18 @@ public void SetPreviewPanel(LobbyCharacterPreviewPanel? panel)
UpdateCharacterUI();
}

public void SetDummyJob(JobPrototype? job, RoleLoadout? loadout)
public void SetDummyJob(JobPrototype? job)
{
_dummyJob = job;
UpdateCharacterUI();
}

public void UpdateCharacterUI()
{
// Test moment
if (_stateManager.CurrentState is not LobbyState)
return;

if (!_preferencesManager.ServerDataLoaded)
{
_previewPanel?.SetLoaded(false);
Expand Down
97 changes: 0 additions & 97 deletions Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs

This file was deleted.

22 changes: 22 additions & 0 deletions Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<Control
xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
<BoxContainer Name="VBox" Orientation="Vertical">
<controls:NanoHeading Name="Header" Text="{Loc 'lobby-character-preview-panel-header'}">

</controls:NanoHeading>
<BoxContainer Name="Loaded" Orientation="Vertical"
Visible="False">
<Label Name="Summary" HorizontalAlignment="Center" Margin="3 3"/>
<BoxContainer Name="ViewBox" Orientation="Horizontal" HorizontalAlignment="Center">

</BoxContainer>
<controls:VSpacer/>
<Button Name="CharacterSetup" Text="{Loc 'lobby-character-preview-panel-character-setup-button'}"
HorizontalAlignment="Center"
Margin="0 5 0 0"/>
</BoxContainer>
<Label Name="Unloaded" Text="{Loc 'lobby-character-preview-panel-unloaded-preferences-label'}"/>
</BoxContainer>
</Control>
46 changes: 46 additions & 0 deletions Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System.Numerics;
using Content.Client.UserInterface.Controls;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Lobby.UI;

[GenerateTypedNameReferences]
public sealed partial class LobbyCharacterPreviewPanel : Control
{
public Button CharacterSetupButton => CharacterSetup;

public LobbyCharacterPreviewPanel()
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
UserInterfaceManager.GetUIController<LobbyUIController>().SetPreviewPanel(this);
}

public void SetLoaded(bool value)
{
Loaded.Visible = value;
Unloaded.Visible = !value;
}

public void SetSummaryText(string value)
{
Summary.Text = string.Empty;
}

public void SetSprite(EntityUid uid)
{
ViewBox.DisposeAllChildren();
var spriteView = new SpriteView
{
OverrideDirection = Direction.South,
Scale = new Vector2(4f, 4f),
MaxSize = new Vector2(112, 112),
Stretch = SpriteView.StretchMode.Fill,
};
spriteView.SetEntity(uid);
ViewBox.AddChild(spriteView);
}
}
19 changes: 0 additions & 19 deletions Content.Client/Preferences/UI/HighlightedContainer.cs

This file was deleted.

11 changes: 11 additions & 0 deletions Content.Client/Preferences/UI/HighlightedContainer.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<PanelContainer
xmlns="https://spacestation14.io"
xmlns:graphics="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client">
<PanelContainer.PanelOverride>
<graphics:StyleBoxFlat BackgroundColor="#2F2F35"
ContentMarginTopOverride="10"
ContentMarginBottomOverride="10"
ContentMarginLeftOverride="10"
ContentMarginRightOverride="10"/>
</PanelContainer.PanelOverride>
</PanelContainer>
14 changes: 14 additions & 0 deletions Content.Client/Preferences/UI/HighlightedContainer.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;

namespace Content.Client.Preferences.UI;

[GenerateTypedNameReferences]
public sealed partial class HighlightedContainer : PanelContainer
{
public HighlightedContainer()
{
RobustXamlLoader.Load(this);
}
}
2 changes: 1 addition & 1 deletion Content.Client/Preferences/UI/LoadoutWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
namespace Content.Client.Preferences.UI;

[GenerateTypedNameReferences]
public sealed partial class LoadoutWindow : FancyWindow

Check failure on line 13 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Unhandled exception occured while generating typed Name references: XamlX.XamlParseException: Unable to resolve type VerticalTabContainer from namespace https://spacestation14.io Line 6, position 10.

Check failure on line 13 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Unhandled exception occured while generating typed Name references: XamlX.XamlParseException: Unable to resolve type VerticalTabContainer from namespace https://spacestation14.io Line 6, position 10.

Check failure on line 13 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Unhandled exception occured while generating typed Name references: XamlX.XamlParseException: Unable to resolve type VerticalTabContainer from namespace https://spacestation14.io Line 6, position 10.

Check failure on line 13 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

Unhandled exception occured while generating typed Name references: XamlX.XamlParseException: Unable to resolve type VerticalTabContainer from namespace https://spacestation14.io Line 6, position 10.
{
public event Action<ProtoId<LoadoutGroupPrototype>, ProtoId<LoadoutPrototype>>? OnLoadoutPressed;
public event Action<ProtoId<LoadoutGroupPrototype>, ProtoId<LoadoutPrototype>>? OnLoadoutUnpressed;
Expand All @@ -28,7 +28,7 @@
continue;

var container = new LoadoutGroupContainer(loadout, protoManager.Index(group), session, collection);
LoadoutGroupsContainer.AddTab(container, Loc.GetString(groupProto.Name));

Check failure on line 31 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The name 'LoadoutGroupsContainer' does not exist in the current context

Check failure on line 31 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The name 'LoadoutGroupsContainer' does not exist in the current context

Check failure on line 31 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The name 'LoadoutGroupsContainer' does not exist in the current context

Check failure on line 31 in Content.Client/Preferences/UI/LoadoutWindow.xaml.cs

View workflow job for this annotation

GitHub Actions / YAML Linter

The name 'LoadoutGroupsContainer' does not exist in the current context
_groups.Add(container);

container.OnLoadoutPressed += args =>
Expand All @@ -47,7 +47,7 @@
{
base.Close();
var controller = UserInterfaceManager.GetUIController<LobbyUIController>();
controller.SetDummyJob(null, null);
controller.SetDummyJob(null);
}

public void RefreshLoadouts(RoleLoadout loadout, ICommonSession session, IDependencyCollection collection)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Preferences/UI/RequirementsSelector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected void Setup(RoleLoadout? loadout, (string, int)[] items, string title,
if (Proto is JobPrototype jobProto)
{
var controller = UserInterfaceManager.GetUIController<LobbyUIController>();
controller.SetDummyJob(jobProto, _loadout);
controller.SetDummyJob(jobProto);
}

_loadoutWindow.OnLoadoutUnpressed += (selectedGroup, selectedLoadout) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public async Task DeleteAllThenGhost()
await using var pair = await PoolManager.GetServerClient(settings);

// Client is connected with a valid entity & mind
Assert.That(pair.Client.EntMan.EntityExists(pair.Client.Player?.ControlledEntity));
Assert.That(pair.Client.EntMan.EntityExists(pair.Client.AttachedEntity));
Assert.That(pair.Server.EntMan.EntityExists(pair.PlayerData?.Mind));

// Delete **everything**
Expand All @@ -28,6 +28,12 @@ public async Task DeleteAllThenGhost()
await pair.RunTicksSync(5);

Assert.That(pair.Server.EntMan.EntityCount, Is.EqualTo(0));

foreach (var ent in pair.Client.EntMan.GetEntities())
{
Console.WriteLine(pair.Client.EntMan.ToPrettyString(ent));
}

Assert.That(pair.Client.EntMan.EntityCount, Is.EqualTo(0));

// Create a new map.
Expand All @@ -36,7 +42,7 @@ public async Task DeleteAllThenGhost()
await pair.RunTicksSync(5);

// Client is not attached to anything
Assert.That(pair.Client.Player?.ControlledEntity, Is.Null);
Assert.That(pair.Client.AttachedEntity, Is.Null);
Assert.That(pair.PlayerData?.Mind, Is.Null);

// Attempt to ghost
Expand All @@ -45,9 +51,9 @@ public async Task DeleteAllThenGhost()
await pair.RunTicksSync(10);

// Client should be attached to a ghost placed on the new map.
Assert.That(pair.Client.EntMan.EntityExists(pair.Client.Player?.ControlledEntity));
Assert.That(pair.Client.EntMan.EntityExists(pair.Client.AttachedEntity));
Assert.That(pair.Server.EntMan.EntityExists(pair.PlayerData?.Mind));
var xform = pair.Client.Transform(pair.Client.Player!.ControlledEntity!.Value);
var xform = pair.Client.Transform(pair.Client.AttachedEntity!.Value);
Assert.That(xform.MapID, Is.EqualTo(new MapId(mapId)));

await pair.CleanReturnAsync();
Expand Down
Loading