mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-17 13:37:47 +03:00
# Description This sucked, this sucks less now. --- # TODO - [x] Use ABGC on Jobs - [x] Use ABGC on Antags - [x] Improve marking editor - [x] Make it use real toggleable Buttons - [x] Remove the enabled/sort order side - [x] Make buttons bigger and improve previews - Move it to the Appearance tab https://github.com/Simple-Station/Einstein-Engines/pull/2241 - [x] Add a Clear button to the search - [x] Display all 4 sprite directions at once instead of using the stupid rotation thing - [x] Move import/export/save buttons - [x] Move name somewhere within the tabs - Load markings after other stuff in the profile <!-- Another PR CharacterRequirements don't need to be given dependencies Markings use CharacterRequirements --> --- <details><summary><h1>Media</h1></summary> <p>       </p> </details> --- # Changelog 🆑 - tweak: Improved readability of many parts of the character editor with colored rows - tweak: Cleaned up some little bits of the character editor, most notably removing a tiny margin that was shrinking every tab - fix: Fixed the style of the Background tab of the character editor being very wonky due to misplaced UI elements - tweak: Made the Jobs tab use proper headers for the department titles - tweak: Improved the Marking editor - tweak: Improved the layout of the character editor - tweak: Improved some button names in the character editor - add: The character editor now shows all 4 directions of your character preview at once --------- Co-authored-by: VMSolidus <evilexecutive@gmail.com> (cherry picked from commit 7e5b3345409dfdabde4ea56d3ecdd34a5ecdd46f)
111 lines
3.5 KiB
C#
111 lines
3.5 KiB
C#
using System.Linq;
|
|
using System.Numerics;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Timing;
|
|
|
|
|
|
namespace Content.Client.UserInterface.Controls;
|
|
|
|
/// <summary>
|
|
/// A box container that gives every child an alternating background color
|
|
/// </summary>
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class AlternatingBGContainer : BoxContainer
|
|
{
|
|
/// If the <see cref="ContentContainer"/>'s horizontal scroll is enabled
|
|
public bool HScrollEnabled => ContentScrollContainer.HScrollEnabled;
|
|
/// If the <see cref="ContentContainer"/>'s vertical scroll is enabled
|
|
public bool VScrollEnabled => ContentScrollContainer.VScrollEnabled;
|
|
|
|
public new bool HorizontalExpand
|
|
{
|
|
get => base.HorizontalExpand;
|
|
set
|
|
{
|
|
base.HorizontalExpand = value;
|
|
Container.HorizontalExpand = value;
|
|
ContentScrollContainer.HorizontalExpand = value;
|
|
ContentContainer.HorizontalExpand = value;
|
|
}
|
|
}
|
|
public new bool VerticalExpand
|
|
{
|
|
get => base.VerticalExpand;
|
|
set
|
|
{
|
|
base.VerticalExpand = value;
|
|
Container.VerticalExpand = value;
|
|
ContentScrollContainer.VerticalExpand = value;
|
|
ContentContainer.VerticalExpand = value;
|
|
}
|
|
}
|
|
|
|
public Thickness ItemMargins = new(4);
|
|
|
|
/// The list of colors to alternate between
|
|
public List<Color> Colors = new()
|
|
{
|
|
Color.FromHex("#25252A"),
|
|
// Color.FromHex("#202025"),
|
|
Color.FromHex("#1B1B1E"),
|
|
};
|
|
|
|
|
|
/// <inheritdoc cref="AlternatingBGContainer"/>
|
|
public AlternatingBGContainer()
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
}
|
|
|
|
private bool _initialized;
|
|
/// Stupid hack, when will I get an initialized event?
|
|
/// This makes anything added via AddControl before first frame show up before children
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
|
|
if (_initialized)
|
|
return;
|
|
|
|
foreach (var child in Children.ToArray())
|
|
if (child != Container)
|
|
AddControl(child);
|
|
UpdateColors(); // Just in case
|
|
_initialized = true;
|
|
}
|
|
|
|
/// Move a control to the container and set their background color
|
|
public void AddControl(Control control)
|
|
{
|
|
var panel = new PanelContainer
|
|
{
|
|
PanelOverride = new StyleBoxFlat { BackgroundColor = Colors[ContentContainer.Children.Count(c => c.Visible) % Colors.Count], },
|
|
HorizontalExpand = true,
|
|
VerticalExpand = true,
|
|
Visible = control.Visible,
|
|
};
|
|
|
|
// Please let me add Thicknesses
|
|
control.Margin = new(control.Margin.Left + ItemMargins.Left, control.Margin.Top + ItemMargins.Top, control.Margin.Right + ItemMargins.Right, control.Margin.Bottom + ItemMargins.Bottom);
|
|
control.Orphan();
|
|
panel.AddChild(control);
|
|
ContentContainer.AddChild(panel);
|
|
}
|
|
|
|
/// Updates the colors of every child
|
|
public void UpdateColors()
|
|
{
|
|
var list = ContentContainer.Children.Where(c => c.Visible).ToList();
|
|
foreach (var child in list)
|
|
{
|
|
if (child is PanelContainer panel)
|
|
((StyleBoxFlat) panel.PanelOverride!).BackgroundColor = Colors[list.IndexOf(panel) % Colors.Count];
|
|
child.Visible = child.Children.First().Visible;
|
|
}
|
|
}
|
|
}
|