forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'SerbiaStrong-220:master' into OkroshkaMedalsResprite
- Loading branch information
Showing
56 changed files
with
606 additions
and
195 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
using Content.Shared.SS220.Paper; | ||
|
||
namespace Content.Client.SS220.Paper.Systems; | ||
|
||
public sealed partial class DocumentHelperSystem : SharedDocumentHelperSystem | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<paper220:DocumentHelperWindow xmlns="https://spacestation14.io" | ||
xmlns:paper220="clr-namespace:Content.Client.SS220.Paper.UI" | ||
SetSize="280 250"> | ||
<BoxContainer Name="BodyContainer" Orientation="Horizontal" HorizontalAlignment="Right" MaxWidth="0"> | ||
<Control Name="Body" SetSize="280 250" HorizontalAlignment="Left" Margin="6"> | ||
<Control Margin="-22" MouseFilter="Pass"> | ||
<PanelContainer Name="PaperBackground" StyleClasses="PaperDefaultBorder" VerticalExpand="True" HorizontalExpand="True"/> | ||
</Control> | ||
<BoxContainer Orientation="Vertical" Margin="0 0 18 0"> | ||
<RichTextLabel Text="{Loc 'document-helper-prompt'}" Margin="0 0 0 10"/> | ||
<ScrollContainer VerticalExpand="True"> | ||
<BoxContainer Name="OptionsContainer" Orientation="Vertical"/> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
<ContainerButton Name="ExpandButton" VerticalExpand="True" SetWidth="32" HorizontalAlignment="Right" Margin="0 0 -16 0"> | ||
<TextureRect Name="ExpandIcon" HorizontalAlignment="Center" StyleClasses="ArrowRight"/> | ||
</ContainerButton> | ||
</Control> | ||
</BoxContainer> | ||
</paper220:DocumentHelperWindow> |
160 changes: 160 additions & 0 deletions
160
Content.Client/SS220/Paper/UI/DocumentHelperWindow.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,160 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
using Content.Client.Resources; | ||
using Content.Client.SS220.Paper.Systems; | ||
using Content.Client.SS220.StyleTools; | ||
using Content.Client.Stylesheets; | ||
using Content.Shared.SS220.Paper; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.Graphics; | ||
using Robust.Client.Player; | ||
using Robust.Client.ResourceManagement; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.SS220.Paper.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class DocumentHelperWindow : Control | ||
{ | ||
[Dependency] private readonly IEntityManager _entityManager = default!; | ||
[Dependency] private readonly IPlayerManager _player = default!; | ||
[Dependency] private readonly IResourceCache _resourceCache = default!; | ||
[Dependency] private readonly IStylesheetManager _stylesheetManager = default!; | ||
|
||
private const string DocumentHelperOptionLocPrefix = "document-helper-option-"; | ||
|
||
private readonly SharedDocumentHelperSystem _documentHelper; | ||
private readonly Dictionary<DocumentHelperOptions, BoxContainer> _optionContainer = []; | ||
private bool _isExpanded = false; | ||
|
||
public event Action<string>? OnButtonPressed; | ||
|
||
public DocumentHelperWindow() : this(DocumentHelperOptions.All) { } | ||
|
||
public DocumentHelperWindow(DocumentHelperOptions options = DocumentHelperOptions.All) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
RobustXamlLoader.Load(this); | ||
|
||
Stylesheet = new DocumentHelperWindowStyle().Create(_stylesheetManager.SheetNano, _resourceCache); | ||
|
||
ExpandButton.OnPressed += args => | ||
{ | ||
SetExpanded(!_isExpanded); | ||
}; | ||
SetExpanded(_isExpanded); | ||
|
||
_documentHelper = _entityManager.System<DocumentHelperSystem>(); | ||
|
||
var optionValuesPair = _documentHelper.GetOptionValuesPair(options, _player.LocalSession?.AttachedEntity); | ||
GenerateOptions(optionValuesPair); | ||
} | ||
|
||
public void GenerateOptions(Dictionary<DocumentHelperOptions, List<string>> optionValuesPair) | ||
{ | ||
foreach (var (option, values) in optionValuesPair) | ||
{ | ||
BoxContainer container; | ||
if (_optionContainer.TryGetValue(option, out var dictContainer)) | ||
{ | ||
container = dictContainer; | ||
container.DisposeAllChildren(); | ||
} | ||
else | ||
{ | ||
container = new BoxContainer | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Horizontal, | ||
VerticalAlignment = VAlignment.Center, | ||
}; | ||
|
||
OptionsContainer.AddChild(container); | ||
} | ||
|
||
var label = new Label | ||
{ | ||
Text = Loc.GetString($"{DocumentHelperOptionLocPrefix + option.ToString().ToLower()}"), | ||
VerticalAlignment = VAlignment.Top, | ||
Margin = new Thickness(0, 6, 0, 0), | ||
}; | ||
label.AddStyleClass("OptionLabel"); | ||
container.AddChild(label); | ||
|
||
var buttonsContainer = new BoxContainer | ||
{ | ||
Orientation = BoxContainer.LayoutOrientation.Vertical | ||
}; | ||
foreach (var value in values) | ||
{ | ||
var button = new Button | ||
{ | ||
Text = value | ||
}; | ||
button.AddStyleClass("OptionButton"); | ||
button.OnPressed += _ => OnButtonPressed?.Invoke(button.Text); | ||
buttonsContainer.AddChild(button); | ||
} | ||
container.AddChild(buttonsContainer); | ||
|
||
_optionContainer[option] = container; | ||
} | ||
} | ||
|
||
public void UpdateState(DocumentHelperOptionsMessage state) | ||
{ | ||
GenerateOptions(state.OptionValuesPair); | ||
} | ||
|
||
private void SetExpanded(bool isExpanded) | ||
{ | ||
_isExpanded = isExpanded; | ||
BodyContainer.Margin = new Thickness(0, 0, isExpanded ? 0 : SetSize.X - 12, 0); | ||
ExpandIcon.TextureScale = new(isExpanded ? -1 : 1, 1); | ||
} | ||
} | ||
|
||
public sealed class DocumentHelperWindowStyle : QuickStyle | ||
{ | ||
protected override void CreateRules() | ||
{ | ||
var placeholder = new StyleBoxTexture { Texture = Resources.GetTexture("/Textures/Interface/Nano/placeholder.png") }; | ||
placeholder.SetPatchMargin(StyleBox.Margin.All, 19); | ||
placeholder.Mode = StyleBoxTexture.StretchMode.Tile; | ||
|
||
Builder.Element<Label>() | ||
.Prop("modulate-self", new Color(10, 10, 10)); | ||
|
||
Builder.Element<RichTextLabel>() | ||
.Prop("modulate-self", new Color(10, 10, 10)); | ||
|
||
Builder.Element<PanelContainer>().Class("PaperDefaultBorder") | ||
.Prop("modulate-self", Color.TryParse("#e7e4df", out var color) ? color : default); | ||
|
||
Builder.Element<TextureRect>().Class("ArrowRight") | ||
.Prop("texture", Tex("/Textures/Interface/Nano/triangle_right_hollow.svg.png")) | ||
.Prop("modulate-self", new Color(10, 10, 10)); | ||
|
||
Builder.Element<Button>().Class("OptionButton") | ||
.Prop("stylebox", placeholder) | ||
.Prop("SetHeight", 34f) | ||
.Prop("Margin", new Thickness(6, 2)); | ||
|
||
Builder.Element<Button>().Class("OptionButton") | ||
.Pseudo("normal") | ||
.Prop("modulate-self", Color.White); | ||
Builder.Element<Button>().Class("OptionButton") | ||
.Pseudo("hover") | ||
.Prop("modulate-self", Color.Gray); | ||
Builder.Element<Button>().Class("OptionButton") | ||
.Pseudo("pressed") | ||
.Prop("modulate-self", Color.Black); | ||
Builder.Element<Button>().Class("OptionButton") | ||
.Pseudo("disabled") | ||
.Prop("modulate-self", Color.White); | ||
|
||
Builder.Element<Button>().Class("OptionButton") | ||
.Child<Label>() | ||
.Prop("Margin", new Thickness(0, -14)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using Content.Server.Station.Systems; | ||
using Content.Shared.Paper; | ||
using Content.Shared.SS220.Paper; | ||
using Robust.Server.GameObjects; | ||
using System.Linq; | ||
using static Content.Shared.Paper.PaperComponent; | ||
|
||
namespace Content.Server.SS220.Paper; | ||
|
||
public sealed partial class DocumentHelperSystem : SharedDocumentHelperSystem | ||
{ | ||
[Dependency] private readonly StationSystem _stationSystem = default!; | ||
[Dependency] private readonly UserInterfaceSystem _ui = default!; | ||
|
||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
} | ||
|
||
#region Ui | ||
public override List<string> GetValuesByOption(DocumentHelperOptions option, EntityUid? uid = null) | ||
{ | ||
List<string> values = []; | ||
switch (option) | ||
{ | ||
case DocumentHelperOptions.Station: | ||
values = values.Union(_stationSystem.GetStationNames().Select(x => x.Name)).ToList(); | ||
break; | ||
default: | ||
values = base.GetValuesByOption(option, uid); | ||
break; | ||
} | ||
|
||
return values; | ||
} | ||
|
||
public override void UpdateUserInterface(Entity<PaperComponent> entity, EntityUid actor) | ||
{ | ||
base.UpdateUserInterface(entity, actor); | ||
var optionValuesPair = GetOptionValuesPair(DocumentHelperOptions.All, actor); | ||
var message = new DocumentHelperOptionsMessage(optionValuesPair); | ||
_ui.ServerSendUiMessage(entity.Owner, PaperUiKey.Key, message, actor); | ||
} | ||
#endregion | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.