forked from space-wizards/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 156
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: lapatison <[email protected]>
- Loading branch information
1 parent
6df44e7
commit 14ff0d4
Showing
115 changed files
with
3,643 additions
and
258 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// © 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.SS220.ButtScan.UI; | ||
using Content.Shared.SS220.ButtScan; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.SS220.ButtScan; | ||
|
||
public sealed class ButtScanBoundUserInterface : BoundUserInterface | ||
{ | ||
[Dependency] private readonly IEntityManager _entityMgr = default!; | ||
|
||
private ButtScanWindow? _window; | ||
private readonly EntityUid _paperEntity; | ||
|
||
public ButtScanBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
_paperEntity = owner.Owner; | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new ButtScanWindow(); | ||
_window.OnClose += Close; | ||
|
||
if (_entityMgr.TryGetComponent<ButtScanComponent>(_paperEntity, out var scan)) | ||
_window.InitVisuals(scan); | ||
|
||
_window.OpenCentered(); | ||
} | ||
|
||
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,20 @@ | ||
<!-- © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt --> | ||
<ui:ButtScanWindow xmlns="https://spacestation14.io" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:ui="clr-namespace:Content.Client.SS220.ButtScan.UI" | ||
|
||
MouseFilter="Stop" | ||
Resizable="False"> | ||
|
||
<BoxContainer Name="ContentsRoot" Orientation="Vertical"> | ||
<PanelContainer StyleClasses="AngleRect" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="6"> | ||
<TextureButton Name="CloseButton" StyleClasses="windowCloseButton"/> | ||
</PanelContainer> | ||
|
||
<PanelContainer Name="ScanBackground" StyleClasses="PaperDefaultBorder" VerticalExpand="True" HorizontalExpand="True"> | ||
<PanelContainer Name="ScanContent" VerticalExpand="True" HorizontalExpand="True"> | ||
<TextureButton Name="ContentsImage" SetSize="300 300" Margin="25 25" HorizontalAlignment="Center" VerticalAlignment="Center" MouseFilter="Ignore"/> | ||
</PanelContainer> | ||
</PanelContainer> | ||
</BoxContainer> | ||
</ui:ButtScanWindow> |
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,32 @@ | ||
// © 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.UserInterface.Controls; | ||
using Content.Shared.SS220.ButtScan; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
|
||
namespace Content.Client.SS220.ButtScan.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class ButtScanWindow : BaseWindow | ||
{ | ||
public ButtScanWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
CloseButton.OnPressed += _ => Close(); | ||
} | ||
|
||
public void InitVisuals(ButtScanComponent scan) | ||
{ | ||
ContentsImage.TexturePath = scan.ButtTexturePath; | ||
ContentsImage.MinSize = ContentsImage.TextureNormal?.Size ?? Vector2.Zero; | ||
} | ||
|
||
// Drag by grabbing anywhere | ||
protected override DragMode GetDragModeFor(Vector2 relativeMousePos) | ||
{ | ||
return DragMode.Move; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Content.Client/SS220/Photocopier/Forms/FormManagerSystem.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,39 @@ | ||
// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt | ||
|
||
using System.Collections.Immutable; | ||
using Content.Shared.SS220.Photocopier.Forms; | ||
using Content.Shared.SS220.Photocopier.Forms.FormManagerShared; | ||
|
||
namespace Content.Client.SS220.Photocopier.Forms; | ||
|
||
/// <summary> | ||
/// Asks server for a complete form tree. Gives it as an immutable to photocopier's UI. | ||
/// </summary> | ||
public sealed class FormManager : EntitySystem | ||
{ | ||
private Dictionary<string, Dictionary<string, FormGroup>> _collections = new(); | ||
private readonly ISawmill _sawmill = Logger.GetSawmill("form-manager"); | ||
|
||
/// <summary> | ||
/// Provides a tree of forms, used by photocopier's UI. | ||
/// </summary> | ||
/// <returns>An immutable dictionary of collections, which are represented as immutable dictionaries of FormGroups</returns> | ||
public ImmutableDictionary<string, ImmutableDictionary<string, FormGroup>> GetImmutableFormsTree() | ||
{ | ||
return _collections.ToImmutableDictionary(pair => pair.Key, pair => pair.Value.ToImmutableDictionary()); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
SubscribeNetworkEvent<PhotocopierFormsMessage>(OnRulesReceived); | ||
_sawmill.Debug("Requested forms from server"); | ||
RaiseNetworkEvent(new RequestPhotocopierFormsMessage()); | ||
} | ||
|
||
private void OnRulesReceived(PhotocopierFormsMessage message, EntitySessionEventArgs args) | ||
{ | ||
_sawmill.Debug("Received forms from server, amount of collections: " + message.Data.Count); | ||
_collections = message.Data; | ||
} | ||
} |
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,78 @@ | ||
// © 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.Photocopier; | ||
using Content.Client.SS220.Photocopier.UI; | ||
using Content.Shared.Containers.ItemSlots; | ||
using Content.Shared.SS220.Photocopier.Forms.FormManagerShared; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.SS220.Photocopier; | ||
|
||
/// <inheritdoc /> | ||
public sealed class PhotocopierBoundUi : BoundUserInterface | ||
{ | ||
private PhotocopierWindow? _window; | ||
|
||
public PhotocopierBoundUi(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
/// <inheritdoc/> | ||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_window = new PhotocopierWindow(); | ||
_window.OpenCentered(); | ||
|
||
_window.OnClose += Close; | ||
_window.PrintButtonPressed += OnPrintButtonPressed; | ||
_window.CopyButtonPressed += OnCopyButtonPressed; | ||
_window.EjectButtonPressed += OnEjectButtonPressed; | ||
_window.StopButtonPressed += OnStopButtonPressed; | ||
_window.RefreshButtonPressed += OnRefreshButtonPressed; | ||
} | ||
|
||
private void OnRefreshButtonPressed() | ||
{ | ||
SendMessage(new PhotocopierRefreshUiMessage()); | ||
} | ||
|
||
private void OnPrintButtonPressed(int amount, FormDescriptor descriptor) | ||
{ | ||
SendMessage(new PhotocopierPrintMessage(amount, descriptor)); | ||
} | ||
|
||
private void OnCopyButtonPressed(int amount) | ||
{ | ||
SendMessage(new PhotocopierCopyMessage(amount)); | ||
} | ||
|
||
private void OnEjectButtonPressed() | ||
{ | ||
SendMessage(new ItemSlotButtonPressedEvent(PhotocopierComponent.PaperSlotId, true, false)); | ||
} | ||
|
||
private void OnStopButtonPressed() | ||
{ | ||
SendMessage(new PhotocopierStopMessage()); | ||
} | ||
|
||
/// <inheritdoc /> | ||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
|
||
if (_window is null || state is not PhotocopierUiState cast) | ||
return; | ||
|
||
_window.UpdateState(cast); | ||
} | ||
|
||
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,115 @@ | ||
// © 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.Photocopier; | ||
using Robust.Client.GameObjects; | ||
|
||
namespace Content.Client.SS220.Photocopier; | ||
|
||
public sealed class PhotocopierSystem : EntitySystem | ||
{ | ||
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; | ||
|
||
private readonly PhotocopierCombinedVisualState _fallbackVisualState = | ||
new(PhotocopierVisualState.Off, false, false); | ||
|
||
/// <inheritdoc/> | ||
public override void Initialize() | ||
{ | ||
base.Initialize(); | ||
|
||
SubscribeLocalEvent<PhotocopierComponent, AppearanceChangeEvent>(OnAppearanceChange); | ||
SubscribeLocalEvent<PhotocopierComponent, AnimationCompletedEvent>(OnAnimationCompleted); | ||
} | ||
|
||
private void OnAppearanceChange(EntityUid uid, PhotocopierComponent component, ref AppearanceChangeEvent args) | ||
{ | ||
if (args.Sprite == null) | ||
return; | ||
|
||
if (!args.AppearanceData.TryGetValue(PhotocopierVisuals.VisualState, out var visualStateObject) || | ||
visualStateObject is not PhotocopierCombinedVisualState visualState) | ||
{ | ||
visualState = _fallbackVisualState; | ||
} | ||
|
||
UpdateAppearance(uid, visualState, component, args.Sprite); | ||
} | ||
|
||
private void OnAnimationCompleted(EntityUid uid, PhotocopierComponent component, AnimationCompletedEvent args) | ||
{ | ||
if (!TryComp<SpriteComponent>(uid, out var sprite)) | ||
return; | ||
|
||
if (!TryComp<AppearanceComponent>(uid, out var appearance) || | ||
!_appearanceSystem.TryGetData<PhotocopierCombinedVisualState>(uid, PhotocopierVisuals.VisualState, out var visualState, appearance)) | ||
{ | ||
visualState = _fallbackVisualState; | ||
} | ||
|
||
UpdateAppearance(uid, visualState, component, sprite); | ||
} | ||
|
||
private static void UpdateAppearance(EntityUid uid, PhotocopierCombinedVisualState visualState, PhotocopierComponent component, SpriteComponent sprite) | ||
{ | ||
SetLayerState(PhotocopierVisualLayers.Base, "off", sprite); | ||
|
||
switch (visualState.State) | ||
{ | ||
case PhotocopierVisualState.Off: | ||
HideLayer(PhotocopierVisualLayers.Led, sprite); | ||
HideLayer(PhotocopierVisualLayers.Top, sprite); | ||
HideLayer(PhotocopierVisualLayers.PrintAnim, sprite); | ||
break; | ||
|
||
case PhotocopierVisualState.Powered: | ||
SetLayerState(PhotocopierVisualLayers.Led, "led_powered", sprite); | ||
SetLayerState(PhotocopierVisualLayers.Top, "top_powered", sprite); | ||
HideLayer(PhotocopierVisualLayers.PrintAnim, sprite); | ||
break; | ||
|
||
case PhotocopierVisualState.OutOfToner: | ||
SetLayerState(PhotocopierVisualLayers.Led, "led_out", sprite); | ||
SetLayerState(PhotocopierVisualLayers.Top, "top_powered", sprite); | ||
HideLayer(PhotocopierVisualLayers.PrintAnim, sprite); | ||
break; | ||
|
||
case PhotocopierVisualState.Printing: | ||
SetLayerState(PhotocopierVisualLayers.Led, "led_printing", sprite); | ||
SetLayerState(PhotocopierVisualLayers.Top, "top_powered", sprite); | ||
SetLayerState(PhotocopierVisualLayers.PrintAnim, "printing_paper", sprite); | ||
break; | ||
|
||
case PhotocopierVisualState.Copying: | ||
SetLayerState(PhotocopierVisualLayers.Led, "led_printing", sprite); | ||
SetLayerState( | ||
PhotocopierVisualLayers.Top, | ||
visualState.Emagged ? "top_scanning_emagged" : "top_scanning", | ||
sprite); | ||
SetLayerState(PhotocopierVisualLayers.PrintAnim, "printing_paper", sprite); | ||
break; | ||
} | ||
|
||
if (visualState.GotItem) | ||
SetLayerState(PhotocopierVisualLayers.TopPaper, "top_paper", sprite); | ||
else | ||
HideLayer(PhotocopierVisualLayers.TopPaper, sprite); | ||
} | ||
|
||
private static void SetLayerState(PhotocopierVisualLayers layer, string? state, SpriteComponent sprite) | ||
{ | ||
if (string.IsNullOrEmpty(state)) | ||
return; | ||
|
||
sprite.LayerSetVisible(layer, true); | ||
sprite.LayerSetAutoAnimated(layer, true); | ||
sprite.LayerSetState(layer, state); | ||
} | ||
|
||
private static void HideLayer(PhotocopierVisualLayers layer, SpriteComponent sprite) | ||
{ | ||
if (!sprite.LayerMapTryGet(layer, out var actualLayer)) | ||
return; | ||
|
||
sprite.LayerSetVisible(actualLayer, false); | ||
} | ||
} |
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,11 @@ | ||
<!-- © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt --> | ||
|
||
<Button xmlns="https://spacestation14.io" xmlns:ui="clr-namespace:Content.Client.SS220.Photocopier.UI"> | ||
<AnimatedTextureRect | ||
Visible="False" | ||
Name="Icon" | ||
HorizontalAlignment="Center" | ||
VerticalAlignment="Center" | ||
HorizontalExpand="True" | ||
VerticalExpand="True"/> | ||
</Button> |
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,29 @@ | ||
// © 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.Stylesheets; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Utility; | ||
|
||
namespace Content.Client.SS220.Photocopier.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class IconButton : Button | ||
{ | ||
public IconButton() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
} | ||
|
||
public string? IconTexture | ||
{ | ||
set | ||
{ | ||
Icon.Visible = value != null; | ||
|
||
if (value is not null) | ||
Icon.SetFromSpriteSpecifier(new SpriteSpecifier.Texture(new ResPath(value))); | ||
} | ||
} | ||
} |
Oops, something went wrong.