Skip to content
Draft
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
4 changes: 4 additions & 0 deletions Content.Client/Lobby/UI/HumanoidProfileEditor.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:ui="clr-namespace:Content.Client.Lobby.UI"
xmlns:profile="clr-namespace:Content.Client.Lobby.UI.ProfileEditorControls"
xmlns:loadouts="clr-namespace:Content.Client._DEN.Lobby.UI.Loadouts"
HorizontalExpand="True">
<!-- Left side -->
<BoxContainer Orientation="Vertical" Margin="10 10 10 10" HorizontalExpand="True">
Expand Down Expand Up @@ -130,6 +131,9 @@
<!-- Markings -->
<humanoid:MarkingPicker Name="Markings" HorizontalExpand="True" VerticalExpand="True" />
</BoxContainer>
<BoxContainer Name="LoadoutTab" Orientation="Vertical" Margin="10">
<loadouts:LoadoutProfilesContainer Name="DenLoadouts" HorizontalExpand="True" VerticalExpand="True" />
</BoxContainer>
</TabContainer>
</BoxContainer>
<!-- Right side -->
Expand Down
8 changes: 7 additions & 1 deletion Content.Client/Lobby/UI/HumanoidProfileEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ public HumanoidProfileEditor(

#endregion Markings

#region Den Loadouts

TabContainer.SetTabTitle(5, "Loadouts"); // TODO: localize

#endregion

RefreshFlavorText();

#region Dummy
Expand Down Expand Up @@ -379,7 +385,7 @@ public void SetProfile(HumanoidCharacterProfile? profile, int? slot)

RefreshAntags();
RefreshJobs();
RefreshLoadouts();
RefreshDenLoadouts();
RefreshSpecies();
RefreshTraits();
RefreshFlavorText();
Expand Down
17 changes: 17 additions & 0 deletions Content.Client/_DEN/Lobby/UI/HumanoidProfileEditor.Loadouts.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Content.Client.Lobby.UI;

public sealed partial class HumanoidProfileEditor
{
private void RefreshDenLoadouts()
{
DenLoadouts.OnPreferenceUpdated += profile =>
{
Profile = profile;
SetDirty();
};

DenLoadouts.SetProfile(Profile);
DenLoadouts.RefreshCategories();
DenLoadouts.RefreshLoadoutItemCategories();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Content.Shared._DEN.Loadout;

namespace Content.Client._DEN.Lobby.UI.Loadouts;

public sealed partial class LoadoutProfilesContainer
{
public void OnClickEditJobLoadouts(DenLoadoutProfile loadoutProfile)
{

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using Content.Shared._DEN.Loadout;

namespace Content.Client._DEN.Lobby.UI.Loadouts;

public sealed partial class LoadoutProfilesContainer
{
private void OnClickEditLoadoutProfile(DenLoadoutProfile loadoutProfile)
{
OnTryCreateLoadout(loadoutProfile);
}

private void OnClickDeleteLoadoutProfile(DenLoadoutProfile loadoutProfile)
{
_profile = _profile?.WithoutLoadoutProfile(loadoutProfile);
SetDirty(_profile);

RefreshCategories();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
using System.Linq;
using Content.Client.Stylesheets;
using Content.Shared._DEN.Loadout;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Prototypes;

namespace Content.Client._DEN.Lobby.UI.Loadouts;

public sealed partial class LoadoutProfilesContainer
{
private readonly Dictionary<ProtoId<LoadoutCategoryPrototype>, LoadoutCategoryPrototype> _loadoutCategories = new();

private readonly Dictionary<ProtoId<LoadoutCategoryPrototype>, ProtoId<LoadoutCategoryPrototype>>
_parents = new();
private readonly Dictionary<ProtoId<EntityLoadoutPrototype>, EntityLoadoutPrototype> _loadoutEntities = new();
private readonly HashSet<ProtoId<LoadoutCategoryPrototype>> _root = new();
private readonly Dictionary<ProtoId<LoadoutCategoryPrototype>, Button> _categoryButtons = new();

public ProtoId<LoadoutCategoryPrototype>? CurrentCategory = null;

private void OnClickEditLoadouts(DenLoadoutProfile loadoutProfile)
{
LoadoutItemSelection.Visible = !LoadoutContainer.Visible;
LoadoutProfileSelection.Visible = !LoadoutContainer.Visible;
}

private void CacheLoadouts()
{
_loadoutCategories.Clear();
_parents.Clear();
_loadoutEntities.Clear();

foreach (var category in _protoMan.EnumeratePrototypes<LoadoutCategoryPrototype>())
{
foreach (var child in category.SubCategories)
{
_parents[child] = category;
}

if (category.Root && !_parents.ContainsKey(category))
_root.Add(category);

_loadoutCategories.Add(category, category);
}

foreach (var loadoutItem in _protoMan.EnumeratePrototypes<EntityLoadoutPrototype>())
{
_loadoutEntities.Add(loadoutItem, loadoutItem);
}
}

public void RefreshLoadoutItemCategories()
{
HashSet<LoadoutCategoryPrototype> allCategories;

foreach (var button in _categoryButtons.Values)
{
button.Orphan();
}

_categoryButtons.Clear();

if (CurrentCategory != null)
{
allCategories = _loadoutCategories[CurrentCategory.Value]
.SubCategories
.Select(c => _loadoutCategories[c])
.ToHashSet();
}
else
{
allCategories = _root
.Select(c => _loadoutCategories[c])
.ToHashSet();
}

var (itemCategories, subCategories) = GetCategoryTypes(allCategories);

foreach (var category in itemCategories)
{
var button = new Button
{
Text = category.Name,
Margin = new Thickness(5, 1),
HorizontalExpand = true,
SetHeight = 25
};

LoadoutItemSelection.LoadoutItemCategoryContainer.AddChild(button);
_categoryButtons.Add(category, button);
}

foreach (var category in subCategories)
{
var button = new Button
{
Text = "boo",
Margin = new Thickness(5, 1),
HorizontalExpand = true,
SetHeight = 25,
StyleClasses = { "ButtonColorGreen" }
};

LoadoutItemSelection.LoadoutItemCategoryContainer.AddChild(button);
_categoryButtons.Add(category, button);
}
}

private (HashSet<LoadoutCategoryPrototype> ItemCategories,
HashSet<LoadoutCategoryPrototype> SubCategories) GetCategoryTypes(HashSet<LoadoutCategoryPrototype> allCategories)
{
var itemCategories = new HashSet<LoadoutCategoryPrototype>();
var subCategories = new HashSet<LoadoutCategoryPrototype>();

foreach (var category in allCategories)
{
if (category.SubCategories.Count > 0)
{
subCategories.Add(category);
continue;
}

itemCategories.Add(category);
}

return (itemCategories, subCategories);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
using Content.Client._DEN.Lobby.UI.Loadouts.Popups;
using Content.Shared._DEN.Loadout;
using Robust.Shared.Prototypes;

namespace Content.Client._DEN.Lobby.UI.Loadouts;

public sealed partial class LoadoutProfilesContainer
{
private void OnTryCreateCategory(LoadoutProfileCategory? existingCategory = null)
{
if (_createCategoryPopup != null)
return;

_createCategoryPopup = new Popups.CreateCategoryPopup(existingCategory);
_createCategoryPopup.OnSubmit += OnSubmitNewCategory;
_createCategoryPopup.OnClose += OnCloseCategoryPopup;
_createCategoryPopup.OpenCentered();
}

private void OnSubmitNewCategory(CategoryCreationRequest request)
{
if (string.IsNullOrEmpty(request.CategoryName))
return;

var guid = request.ExistingCategoryId ?? Guid.NewGuid();
var priority = 100;
var members = new HashSet<Guid>();

if (_profile?.LoadoutCategories.TryGetValue(guid, out var loadout) == true)
{
priority = loadout.Priority;
members.UnionWith(loadout.Members);
}

var category = new LoadoutProfileCategory
{
Id = guid,
Color = request.CategoryColor.ToHex(),
Name = request.CategoryName,
Priority = priority,
Members = members
};

_profile = _profile?.WithLoadoutCategory(guid, category);
OnPreferenceUpdated?.Invoke(_profile);

RefreshCategories();
OnCloseCategoryPopup();
}

private void OnTryCreateLoadout(DenLoadoutProfile? loadout = null)
{
if (_createLoadoutPopup != null)
return;

_createLoadoutPopup = new Popups.CreateLoadoutPopup(_popupCategories, loadout);
_createLoadoutPopup.OnSubmit += OnSubmitNewLoadout;
_createLoadoutPopup.OnClose += OnCloseLoadoutPopup;
_createLoadoutPopup.OpenCentered();
}

private void OnSubmitNewLoadout(LoadoutCreationRequest request)
{
if (string.IsNullOrEmpty(request.LoadoutName))
return;

var guid = Guid.NewGuid();
var priority = 100;
var loadouts = new HashSet<ProtoId<EntityLoadoutPrototype>>();

if (request.ExistingLoadoutId is { } loadoutProfileId
&& _profile?.LoadoutProfiles.TryGetValue(loadoutProfileId, out var loadoutProfile) == true)
{
guid = loadoutProfile.Id;
priority = loadoutProfile.Priority;
loadouts.UnionWith(loadoutProfile.Loadouts);
}

var loadout = new DenLoadoutProfile
{
Id = guid,
Name = request.LoadoutName,
LoadoutCategory = request.CategoryId,
Priority = priority,
Loadouts = loadouts,
};

_profile = _profile?.WithLoadoutProfile(guid, request.CategoryId, loadout);
SetDirty(_profile);

RefreshCategories();
OnCloseLoadoutPopup();
}

private void OnCloseCategoryPopup()
{
_createCategoryPopup?.Orphan();
_createCategoryPopup = null;
}

private void OnCloseLoadoutPopup()
{
_createLoadoutPopup?.Orphan();
_createLoadoutPopup = null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<loadouts:LoadoutProfilesContainer xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:loadouts="clr-namespace:Content.Client._DEN.Lobby.UI.Loadouts"
xmlns:subcontainers="clr-namespace:Content.Client._DEN.Lobby.UI.Loadouts.Subcontainers">
<BoxContainer HorizontalExpand="True"
VerticalExpand="True">
<subcontainers:LoadoutItemSelection Name="LoadoutItemSelection"
HorizontalExpand="True"
VerticalExpand="True"
Visible="True"/>
<BoxContainer Name="LoadoutProfileSelection"
Orientation="Vertical"
HorizontalExpand="True"
SeparationOverride="0"
Visible="False">
<PanelContainer SetHeight="50"
HorizontalExpand="True"
StyleClasses="ChatPanel">
<BoxContainer Margin="5 0 5 0">
<Label Text="Loadouts"
Margin="15 0 0 0"
StyleClasses="LabelHeading" />
<Control HorizontalExpand="True"></Control>
<Button Name="ButtonCreateCategory"
Text="Create New Category"
SetHeight="35"
StyleClasses="OpenRight" />
<Button Name="ButtonCreateLoadout"
Text="Create New Loadout"
SetHeight="35"
StyleClasses="OpenLeft" />
</BoxContainer>
</PanelContainer>
<PanelContainer Name="WarningsContainer"
SetHeight="50"
HorizontalExpand="True"
StyleClasses="ChatPanel"
Margin="0 5 0 0"
Visible="False">
<BoxContainer Margin="5 0 5 0">
<RichTextLabel Name="WarningsText" Text="You have [color=#ffa21f]2[/color] unresolved loadout issues. " Margin="15 0 0 0" />
<Control HorizontalExpand="True"></Control>
<Button Name="ButtonViewWarnings"
Text="View Warnings"
SetHeight="35" />
</BoxContainer>
</PanelContainer>
<PanelContainer SetHeight="3" HorizontalExpand="True" Margin="0 10 0 6">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="#393947" />
</PanelContainer.PanelOverride>
</PanelContainer>
<BoxContainer HorizontalExpand="True"
VerticalExpand="True"
Orientation="Vertical"
Margin="0 5 0 0">
<PanelContainer HorizontalExpand="True"
VerticalExpand="True">
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BorderColor="#1F1F23" BorderThickness="1" />
</PanelContainer.PanelOverride>
<BoxContainer Name="LoadoutContainer"
Orientation="Vertical">
<!-- <ui:DenCategoryContainer /> -->
</BoxContainer>
</PanelContainer>
</BoxContainer>
</BoxContainer>
</BoxContainer>
</loadouts:LoadoutProfilesContainer>
Loading
Loading