forked from SerbiaStrong-220/space-station-14
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ui * uifix * uiLog * uiLogFix
- Loading branch information
Showing
13 changed files
with
380 additions
and
11 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
Content.Client/AWS/Economy/UI/EconomyLogConsoleBoundUserInterface.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,33 @@ | ||
using Content.Shared.AWS.Economy; | ||
using Content.Client.AWS.Economy.UI; | ||
|
||
namespace Content.Client.AWS.Economy.UI; | ||
|
||
public sealed class EconomyLogConsoleBoundUserInterface : BoundUserInterface | ||
{ | ||
[ViewVariables] | ||
private EconomyLogConsoleMenu? _menu; | ||
|
||
public EconomyLogConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
|
||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_menu = new EconomyLogConsoleMenu(this); | ||
_menu.OnClose += Close; | ||
|
||
_menu.OpenCentered(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (!disposing) | ||
return; | ||
_menu?.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,25 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="Bank Accounts" | ||
MinSize="800 400" | ||
Resizable="False"> | ||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True" VerticalExpand="True"> | ||
<!-- Left: Account List --> | ||
<BoxContainer Orientation="Vertical" Margin="5" MinWidth="300"> | ||
<Label Text="{Loc 'economybanksystem-console-accounts-title'}" HorizontalExpand="True" Align="Center"/> | ||
<LineEdit Name="FindAccount" HorizontalExpand="True" /> | ||
<ScrollContainer VerticalExpand="True"> | ||
<ItemList Name="AccountList" /> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
|
||
<!-- Right: Account Logs --> | ||
<BoxContainer Orientation="Vertical" Margin="5" VerticalExpand="True" HorizontalExpand="True"> | ||
<Label Text="{Loc 'economybanksystem-console-logs-title'}" HorizontalExpand="True" Align="Center"/> | ||
<LineEdit Name="FindLog" HorizontalExpand="True" /> | ||
<ScrollContainer VerticalExpand="True"> | ||
<ItemList Name="LogDetails" /> | ||
</ScrollContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
114 changes: 114 additions & 0 deletions
114
Content.Client/AWS/Economy/UI/EconomyLogConsoleMenu.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,114 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.AWS.Economy; | ||
using Content.Client.AWS.Economy.UI; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Client.UserInterface.Controls; | ||
using System.Linq; | ||
using Microsoft.CodeAnalysis.CSharp.Syntax; | ||
using YamlDotNet.Core.Tokens; | ||
|
||
namespace Content.Client.AWS.Economy.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class EconomyLogConsoleMenu : FancyWindow | ||
{ | ||
[Dependency] private readonly IEntitySystemManager _entitySystem = default!; | ||
private EconomyLogConsoleBoundUserInterface Owner { get; set; } | ||
private Dictionary<string, EconomyBankAccountComponent> _accounts; | ||
public EconomyLogConsoleMenu(EconomyLogConsoleBoundUserInterface owner) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
RobustXamlLoader.Load(this); | ||
var economyBankAccount = _entitySystem.GetEntitySystem<EconomyBankAccountSystemShared>(); | ||
|
||
LogDetails.SelectMode = ItemList.ItemListSelectMode.None; | ||
|
||
Owner = owner; | ||
_accounts = economyBankAccount.GetAccounts(); | ||
|
||
FillList(); | ||
|
||
FindAccount.OnTextEntered += OnTextEnteredAccount; | ||
FindLog.OnTextEntered += OnTextEnteredLog; | ||
|
||
} | ||
|
||
private void OnSelectAccount(ItemList.Item accountId) | ||
{ | ||
LogDetails.Clear(); | ||
|
||
var accountComponent = (accountId.Metadata! as EconomyBankAccountComponent)!; | ||
|
||
if (accountComponent.Logs.Count == 0) | ||
{ | ||
LogDetails.AddItem("No logs detected"); | ||
return; | ||
} | ||
for (int i = accountComponent.Logs.Count - 1; i != -1; i--) | ||
{ | ||
var item = accountComponent.Logs[i]; | ||
LogDetails.AddItem("[" + item.Date.ToString("hh\\:mm\\:ss") + "] — " + item.Text); | ||
} | ||
} | ||
|
||
private void OnTextEnteredAccount(LineEdit.LineEditEventArgs eventArgs) | ||
{ | ||
AccountList.Clear(); | ||
var upText = eventArgs.Text.ToUpper(); | ||
foreach (var (key, value) in _accounts) | ||
{ | ||
var fieldName = FormFieldName(value); | ||
if (fieldName.Contains(upText)) | ||
{ | ||
var field = AccountList.AddItem(fieldName); | ||
field.Metadata = value; | ||
field.OnSelected += OnSelectAccount; | ||
} | ||
} | ||
if (AccountList.Count == 0) | ||
{ | ||
AccountList.AddItem("No data acquired"); | ||
return; | ||
} | ||
AccountList.SortItemsByText(); | ||
} | ||
private void OnTextEnteredLog(LineEdit.LineEditEventArgs eventArgs) | ||
{ | ||
|
||
if (!AccountList.GetSelected().Any()) | ||
{ | ||
LogDetails.Clear(); | ||
LogDetails.AddItem("Error no select Account"); | ||
return; | ||
} | ||
var accountId = AccountList.GetSelected().First(); | ||
LogDetails.Clear(); | ||
var upText = eventArgs.Text.ToUpper(); | ||
|
||
var accountComponent = (accountId.Metadata! as EconomyBankAccountComponent)!; | ||
|
||
for (int i = accountComponent.Logs.Count - 1; i != -1; i--) | ||
{ | ||
var item = accountComponent.Logs[i]; | ||
if (item.Text.Contains(upText)) | ||
LogDetails.AddItem("[" + item.Date.ToString("hh\\:mm\\:ss") + "] — " + item.Text); | ||
} | ||
} | ||
|
||
private void FillList() | ||
{ | ||
foreach (var (key, value) in _accounts) | ||
{ | ||
var field = AccountList.AddItem(FormFieldName(value)); | ||
field.Metadata = value; | ||
field.OnSelected += OnSelectAccount; | ||
} | ||
AccountList.SortItemsByText(); | ||
} | ||
|
||
private string FormFieldName(EconomyBankAccountComponent comp) | ||
{ | ||
return comp.AccountId + " — " + comp.AccountName; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
Content.Client/AWS/Economy/UI/EconomyTerminalBoundUserInterface.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,37 @@ | ||
using Content.Shared.AWS.Economy; | ||
using Content.Client.AWS.Economy.UI; | ||
|
||
namespace Content.Client.AWS.Economy.UI; | ||
|
||
public sealed class EconomyTerminalBoundUserInterface : BoundUserInterface | ||
{ | ||
[ViewVariables] | ||
private EconomyTerminalMenu? _menu; | ||
|
||
public EconomyTerminalBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
} | ||
|
||
public void OnPayPressed(ulong amount, string reason) | ||
{ | ||
SendMessage(new EconomyTerminalMessage(amount, reason)); | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
|
||
_menu = new EconomyTerminalMenu(this); | ||
_menu.OnClose += Close; | ||
|
||
_menu.OpenCentered(); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
base.Dispose(disposing); | ||
if (!disposing) | ||
return; | ||
_menu?.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,13 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="Payment Terminal" | ||
MinSize="300 105" | ||
Resizable="False"> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True"> | ||
<Label Text="{Loc 'economy-Terminal-Reason'}" Margin="0 5 0 0"/> | ||
<LineEdit Name="ReasonField" HorizontalExpand="True" /> | ||
<Label Text="{Loc 'economy-Terminal-Amount'}" Margin="0 5 0 0"/> | ||
<SpinBox Name="AmountBox" HorizontalExpand="True" Value="0" /> | ||
<Button Name="SetButton" Text="{Loc 'economy-Terminal-SetButton-button'}" HorizontalExpand="True"/> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
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,24 @@ | ||
using Content.Client.UserInterface.Controls; | ||
using Content.Shared.AWS.Economy; | ||
using Content.Client.AWS.Economy.UI; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Client.UserInterface.Controls; | ||
|
||
namespace Content.Client.AWS.Economy.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class EconomyTerminalMenu : FancyWindow | ||
{ | ||
private EconomyTerminalBoundUserInterface Owner { get; set; } | ||
|
||
public EconomyTerminalMenu(EconomyTerminalBoundUserInterface owner) | ||
{ | ||
IoCManager.InjectDependencies(this); | ||
RobustXamlLoader.Load(this); | ||
|
||
Owner = owner; | ||
|
||
SetButton.OnPressed += _ => Owner.OnPayPressed((ulong) AmountBox.Value, ReasonField.Text); | ||
} | ||
} |
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,9 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.AWS.Economy; | ||
|
||
[Serializable, NetSerializable] | ||
public enum EconomyLogConsoleMenuUiKey | ||
{ | ||
Key | ||
} |
15 changes: 15 additions & 0 deletions
15
Content.Shared/AWS/Economy/EconomyTerminalUserInterfaceState.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,15 @@ | ||
using Robust.Shared.Serialization; | ||
|
||
namespace Content.Shared.AWS.Economy; | ||
|
||
[Serializable, NetSerializable] | ||
public sealed class EconomyTerminalMessage(ulong amount, string reason) : BoundUserInterfaceMessage | ||
{ | ||
public readonly ulong Amount = amount; | ||
public readonly string Reason = reason; | ||
} | ||
[Serializable, NetSerializable] | ||
public enum EconomyTerminalUiKey | ||
{ | ||
Key | ||
} |
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
economybanksystem-log-withdraw = Снятие {$amount} {$currencyName} | ||
economybanksystem-log-send-to = Перевод {$amount} {$currencyName} на {$accountId} | ||
economybanksystem-log-send-from = Пополнение на {$amount} {$currencyName} с {$accountId} | ||
economybanksystem-log-vending-buying = Покупка {$itemName} | ||
economybanksystem-log-vending-buying = Покупка {$itemName} | ||
economybanksystem-console-accounts-title = Список счетов | ||
economybanksystem-console-logs-title = Список операций |
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,88 @@ | ||
- type: entity | ||
id: ConsoleLog | ||
parent: BaseMachinePowered | ||
name: LogComp | ||
components: | ||
- type: Sprite | ||
sprite: AWS/economy/ATM.rsi | ||
layers: | ||
- map: ["computerLayerBody"] | ||
state: ATM | ||
- map: ["enum.PowerDeviceVisualLayers.Powered"] | ||
state: ATM-on | ||
shader: unshaded | ||
- map: ["enum.WiresVisualLayers.MaintenancePanel"] | ||
state: panel | ||
visible: false | ||
- type: GenericVisualizer | ||
visuals: | ||
enum.PowerDeviceVisuals.Powered: | ||
enum.PowerDeviceVisualLayers.Powered: | ||
True: { visible: true } | ||
False: { visible: false } | ||
- type: Icon | ||
sprite: AWS/economy/ATM.rsi | ||
state: icon | ||
- type: Physics | ||
bodyType: Static | ||
- type: Transform | ||
noRot: true | ||
- type: Fixtures | ||
fixtures: | ||
fix1: | ||
shape: | ||
!type:PhysShapeAabb | ||
bounds: "-0.25,-0.45,0.25,0.45" | ||
mask: | ||
- MachineMask | ||
layer: | ||
- MachineLayer | ||
density: 200 | ||
- type: Destructible | ||
thresholds: | ||
- trigger: | ||
!type:DamageTrigger | ||
damage: 100 | ||
behaviors: | ||
- !type:DoActsBehavior | ||
acts: ["Breakage"] | ||
- !type:EjectVendorItems | ||
- trigger: | ||
!type:DamageTrigger | ||
damage: 200 | ||
behaviors: | ||
- !type:SpawnEntitiesBehavior | ||
spawn: | ||
SheetSteel1: | ||
min: 1 | ||
max: 1 | ||
- !type:DoActsBehavior | ||
acts: [ "Destruction" ] | ||
- !type:PlaySoundBehavior | ||
sound: | ||
collection: MetalGlassBreak | ||
- type: Repairable | ||
doAfterDelay: 8 | ||
- type: ActivatableUI | ||
key: enum.EconomyLogConsoleMenuUiKey.Key | ||
- type: ActivatableUIRequiresPower | ||
- type: UserInterface | ||
interfaces: | ||
enum.EconomyLogConsoleMenuUiKey.Key: | ||
type: EconomyLogConsoleBoundUserInterface | ||
- type: WiresPanel | ||
- type: WiresVisuals | ||
- type: Anchorable | ||
- type: DoAfter | ||
- type: Electrified | ||
enabled: false | ||
usesApcPower: true | ||
- type: PointLight | ||
enabled: false | ||
castShadows: false | ||
radius: 1.5 | ||
- type: LitOnPowered | ||
- type: ApcPowerReceiver | ||
powerLoad: 200 | ||
- type: Actions | ||
- type: Appearance |
Oops, something went wrong.