-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into dorabotochki
- Loading branch information
Showing
935 changed files
with
717,065 additions
and
486,142 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
Content.Client/ADT/BookPrinter/BookPrinterBoundUserInterface.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,72 @@ | ||
using Content.Shared.ADT.BookPrinter; | ||
using Content.Shared.Containers.ItemSlots; | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Client.ADT.BookPrinter | ||
{ | ||
[UsedImplicitly] | ||
public sealed class BookPrinterBoundUserInterface : BoundUserInterface | ||
{ | ||
[ViewVariables] | ||
private BookPrinterWindow? _window; | ||
|
||
[ViewVariables] | ||
private BookPrinterBoundUserInterfaceState? _lastState; | ||
|
||
public BookPrinterBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new() | ||
{ | ||
Title = EntMan.GetComponent<MetaDataComponent>(Owner).EntityName, | ||
}; | ||
|
||
_window.EjectButton.OnPressed += _ => SendMessage(new ItemSlotButtonPressedEvent("bookSlot")); | ||
_window.ClearButton.OnPressed += _ => SendMessage(new BookPrinterClearContainerMessage()); | ||
_window.UploadButton.OnPressed += _ => SendMessage(new BookPrinterUploadMessage()); | ||
_window.CopyPasteButton.OnPressed += _ => SendMessage(new BookPrinterCopyPasteMessage()); | ||
|
||
|
||
_window.OpenCentered(); | ||
_window.OnClose += Close; | ||
|
||
_window.OnPrintBookButtonPressed += (args, button) => SendMessage(new BookPrinterPrintBookMessage(button.BookEntry)); | ||
_window.OnPrintBookButtonMouseEntered += (args, button) => | ||
{ | ||
if (_lastState is not null) | ||
_window.UpdateContainerInfo(_lastState); | ||
}; | ||
_window.OnPrintBookButtonMouseExited += (args, button) => | ||
{ | ||
if (_lastState is not null) | ||
_window.UpdateContainerInfo(_lastState); | ||
}; | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
var castState = (BookPrinterBoundUserInterfaceState)state; | ||
_lastState = castState; | ||
|
||
_window?.UpdateState(castState); | ||
} | ||
|
||
[Obsolete] | ||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
|
||
if (disposing) | ||
{ | ||
_window?.Dispose(); | ||
} | ||
} | ||
} | ||
} |
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,45 @@ | ||
<DefaultWindow | ||
xmlns="https://spacestation14.io" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
Title="{Loc 'book-printer-title'}" | ||
SetSize="525 475" | ||
MinSize="525 475"> | ||
<BoxContainer Orientation="Vertical"> | ||
<ScrollContainer HScrollEnabled="False" HorizontalExpand="True" VerticalExpand="True" MinSize="0 250"> | ||
<BoxContainer Orientation="Vertical" Name="BooksList" Access="Public"> | ||
</BoxContainer> | ||
</ScrollContainer> | ||
<Control MinSize="0 10"/> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Text="{Loc 'book-printer-window-book-label'}"/> | ||
<Control MinSize="10 0"/> | ||
<Button Name="UploadButton" | ||
Access="Public" | ||
Text="{Loc 'book-printer-window-upload-button'}" | ||
StyleClasses="OpenRight"/> | ||
<Button Name="ClearButton" | ||
Access="Public" | ||
Text="{Loc 'book-printer-window-clear-button'}" | ||
StyleClasses="OpenBoth"/> | ||
<Button Name="CopyPasteButton" | ||
Access="Public" | ||
Text="{Loc 'book-printer-window-copy-button'}" | ||
StyleClasses="OpenBoth"/> | ||
<Button Name="EjectButton" | ||
Access="Public" | ||
Text="{Loc 'book-printer-window-eject-button'}" | ||
StyleClasses="OpenLeft"/> | ||
</BoxContainer> | ||
<Control MinSize="0 10"/> | ||
<PanelContainer SizeFlagsStretchRatio="6" MinSize="0 100"> | ||
<PanelContainer.PanelOverride> | ||
<gfx:StyleBoxFlat BackgroundColor="#1b1b1e" /> | ||
</PanelContainer.PanelOverride> | ||
<BoxContainer Name="ContainerInfo" | ||
Orientation="Vertical" | ||
HorizontalExpand="True"> | ||
<Label Text="{Loc 'book-printer-window-no-book-loaded-text'}"/> | ||
</BoxContainer> | ||
</PanelContainer> | ||
</BoxContainer> | ||
</DefaultWindow> |
161 changes: 161 additions & 0 deletions
161
Content.Client/ADT/BookPrinter/BookTerminalWindow.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,161 @@ | ||
using System.Linq; | ||
using System.Numerics; | ||
using Content.Client.Stylesheets; | ||
using Content.Shared.ADT.BookPrinter; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Prototypes; | ||
using static Robust.Client.UserInterface.Controls.BoxContainer; | ||
|
||
namespace Content.Client.ADT.BookPrinter | ||
{ | ||
[GenerateTypedNameReferences] | ||
public sealed partial class BookPrinterWindow : DefaultWindow | ||
{ | ||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!; | ||
[Dependency] private readonly IEntityManager _entMan = default!; | ||
public event Action<BaseButton.ButtonEventArgs, PrintBookButton>? OnPrintBookButtonPressed; | ||
public event Action<GUIMouseHoverEventArgs, PrintBookButton>? OnPrintBookButtonMouseEntered; | ||
public event Action<GUIMouseHoverEventArgs, PrintBookButton>? OnPrintBookButtonMouseExited; | ||
|
||
|
||
public BookPrinterWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
} | ||
|
||
public void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
var castState = (BookPrinterBoundUserInterfaceState)state; | ||
UpdateContainerInfo(castState); | ||
UpdateBooksList(castState); | ||
|
||
CopyPasteButton.Text = Loc.GetString(castState.CopyPaste | ||
? "book-printer-window-paste-button" | ||
: "book-printer-window-copy-button"); | ||
|
||
UploadButton.Disabled = !castState.RoutineAllowed || castState.WorkProgress is not null; | ||
ClearButton.Disabled = !castState.RoutineAllowed || castState.WorkProgress is not null; | ||
EjectButton.Disabled = castState.BookName is null || castState.WorkProgress is not null; | ||
CopyPasteButton.Disabled = !castState.RoutineAllowed || castState.WorkProgress is not null; | ||
} | ||
|
||
public void UpdateBooksList(BoundUserInterfaceState state) | ||
{ | ||
var castState = (BookPrinterBoundUserInterfaceState)state; | ||
|
||
if (BooksList == null) | ||
return; | ||
|
||
BooksList.Children.Clear(); | ||
|
||
if (castState.BookEntries is null) | ||
return; | ||
|
||
|
||
foreach (var entry in castState.BookEntries.OrderBy(r => r.Name)) | ||
{ | ||
var button = new PrintBookButton(entry, CutDescription(entry.Name ?? "")); | ||
button.OnPressed += args => OnPrintBookButtonPressed?.Invoke(args, button); | ||
button.OnMouseEntered += args => OnPrintBookButtonMouseEntered?.Invoke(args, button); | ||
button.OnMouseExited += args => OnPrintBookButtonMouseExited?.Invoke(args, button); | ||
button.Disabled = !castState.RoutineAllowed || castState.WorkProgress is not null; | ||
BooksList.AddChild(button); | ||
} | ||
} | ||
|
||
public string CutDescription(string? text) | ||
{ | ||
if (text is null) | ||
return ""; | ||
|
||
if (text.Length <= 47) | ||
return text; | ||
|
||
return text.Substring(0, 47) + "..."; | ||
} | ||
|
||
public void UpdateContainerInfo(BookPrinterBoundUserInterfaceState state) | ||
{ | ||
ContainerInfo.Children.Clear(); | ||
|
||
if (state.WorkProgress is not null) | ||
{ | ||
ContainerInfo.Children.Add(new Label { Text = Loc.GetString("book-printer-window-working", ("progress", (int)(100.0f * (1 - state.WorkProgress)))) }); | ||
return; | ||
} | ||
|
||
if (state.BookName is null) | ||
{ | ||
ContainerInfo.Children.Add(new Label { Text = Loc.GetString("book-printer-window-no-book-loaded-text") }); | ||
} | ||
else | ||
{ | ||
|
||
var bookPreview = new SpriteView | ||
{ | ||
Scale = new Vector2(2, 2), | ||
OverrideDirection = Direction.South, | ||
VerticalAlignment = VAlignment.Center, | ||
SizeFlagsStretchRatio = 1 | ||
}; | ||
if (_entMan.TryGetEntity(state.BookEntity, out var bookEntity)) | ||
bookPreview.SetEntity(bookEntity); | ||
|
||
var bookLabel = new Label | ||
{ | ||
Text = $"{CutDescription(state.BookName)}" | ||
}; | ||
|
||
var bookSublabel = new Label | ||
{ | ||
Text = $"{CutDescription(state.BookDescription)}", | ||
StyleClasses = { StyleNano.StyleClassLabelSecondaryColor } | ||
}; | ||
|
||
var boxInfo = new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Vertical, | ||
Children = { | ||
new Control { MinSize = new Vector2(0, 10) }, | ||
bookLabel, | ||
bookSublabel } | ||
}; | ||
|
||
ContainerInfo.Children.Add(new BoxContainer | ||
{ | ||
Orientation = LayoutOrientation.Horizontal, | ||
Children = { bookPreview, boxInfo } | ||
}); | ||
|
||
} | ||
|
||
if (state.CartridgeCharge is null) | ||
{ | ||
ContainerInfo.Children.Add(new Label { Text = Loc.GetString("book-printer-window-no-cartridge-loaded-text"), FontColorOverride = Color.DarkRed }); | ||
return; | ||
} | ||
else if (state.CartridgeCharge <= -10.0f) | ||
{ | ||
ContainerInfo.Children.Add(new Label { Text = Loc.GetString("book-printer-window-cartridge-empty"), FontColorOverride = Color.DarkRed }); | ||
return; | ||
} | ||
ContainerInfo.Children.Add(new Label { Text = Loc.GetString("book-printer-window-cartridge-charge", ("charge", (int)(100 * state.CartridgeCharge))) }); | ||
} | ||
} | ||
|
||
public sealed class PrintBookButton : Button | ||
{ | ||
public SharedBookPrinterEntry BookEntry { get; } | ||
|
||
public PrintBookButton(SharedBookPrinterEntry bookEntry, string text) | ||
{ | ||
BookEntry = bookEntry; | ||
Text = text; | ||
} | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
Content.Client/ADT/BookPrinter/Visualizers/BookPrinterlVisualizerSystem.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,63 @@ | ||
using Content.Shared.ADT.BookPrinter.Components; | ||
using Content.Shared.Containers.ItemSlots; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.ADT.BookPrinter.Visualizers; | ||
|
||
public sealed partial class BookPrinterVisualizerSystem : VisualizerSystem<BookPrinterVisualsComponent> | ||
{ | ||
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!; | ||
|
||
protected override void OnAppearanceChange(EntityUid uid, BookPrinterVisualsComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null || !EntityManager.TryGetComponent<ItemSlotsComponent>(uid, out var slotComp)) | ||
return; | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.Working, out var workLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(workLayer, component.DoWorkAnimation); | ||
} | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.Slotted, out var slotLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(slotLayer, (_itemSlotsSystem.GetItemOrNull(uid, "cartridgeSlot") is not null)); | ||
} | ||
|
||
var cartridge = _itemSlotsSystem.GetItemOrNull(uid, "cartridgeSlot"); | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.Full, out var fullLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(fullLayer, false); | ||
if (cartridge is not null && EntityManager.TryGetComponent<BookPrinterCartridgeComponent>(cartridge, out BookPrinterCartridgeComponent? cartridgeComp)) | ||
args.Sprite.LayerSetVisible(fullLayer!, cartridgeComp.CurrentCharge == cartridgeComp.FullCharge); | ||
} | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.High, out var highLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(highLayer, false); | ||
if (cartridge is not null && EntityManager.TryGetComponent<BookPrinterCartridgeComponent>(cartridge, out BookPrinterCartridgeComponent? cartridgeComp)) | ||
args.Sprite.LayerSetVisible(highLayer, cartridgeComp.CurrentCharge >= cartridgeComp.FullCharge / 1.43f && cartridgeComp.CurrentCharge < cartridgeComp.FullCharge); | ||
} | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.Medium, out var mediumLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(mediumLayer, false); | ||
if (cartridge is not null && EntityManager.TryGetComponent<BookPrinterCartridgeComponent>(cartridge, out BookPrinterCartridgeComponent? cartridgeComp)) | ||
args.Sprite.LayerSetVisible(mediumLayer, cartridgeComp.CurrentCharge >= cartridgeComp.FullCharge / 2.5f && cartridgeComp.CurrentCharge < cartridgeComp.FullCharge / 1.43f); | ||
} | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.Low, out var lowLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(lowLayer, false); | ||
if (cartridge is not null && EntityManager.TryGetComponent<BookPrinterCartridgeComponent>(cartridge, out BookPrinterCartridgeComponent? cartridgeComp)) | ||
args.Sprite.LayerSetVisible(lowLayer, cartridgeComp.CurrentCharge > 0 && cartridgeComp.CurrentCharge < cartridgeComp.FullCharge / 2.5f); | ||
} | ||
|
||
if (args.Sprite.LayerMapTryGet(BookPrinterVisualLayers.None, out var noneLayer)) | ||
{ | ||
args.Sprite.LayerSetVisible(noneLayer, false); | ||
if (cartridge is not null && EntityManager.TryGetComponent<BookPrinterCartridgeComponent>(cartridge, out BookPrinterCartridgeComponent? cartridgeComp)) | ||
args.Sprite.LayerSetVisible(noneLayer, cartridgeComp.CurrentCharge < 1); | ||
} | ||
} | ||
} |
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.