diff --git a/Content.Client/Traitor/Uplink/UplinkListingControl.xaml b/Content.Client/Traitor/Uplink/UplinkListingControl.xaml
new file mode 100644
index 0000000000..46fa1062d7
--- /dev/null
+++ b/Content.Client/Traitor/Uplink/UplinkListingControl.xaml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/Content.Client/Traitor/Uplink/UplinkListingControl.xaml.cs b/Content.Client/Traitor/Uplink/UplinkListingControl.xaml.cs
new file mode 100644
index 0000000000..32d5468bc3
--- /dev/null
+++ b/Content.Client/Traitor/Uplink/UplinkListingControl.xaml.cs
@@ -0,0 +1,25 @@
+using Robust.Client.AutoGenerated;
+using Robust.Client.UserInterface;
+using Robust.Client.UserInterface.Controls;
+using Robust.Client.UserInterface.XAML;
+using Robust.Shared.Maths;
+
+namespace Content.Client.Traitor.Uplink
+{
+ [GenerateTypedNameReferences]
+ public partial class UplinkListingControl : Control
+ {
+ public Button UplinkItemBuyButton => UplinkItemBuyButtonProtected;
+
+ public UplinkListingControl(string itemName, string itemDescription, int itemPrice, bool canBuy)
+ {
+ RobustXamlLoader.Load(this);
+
+ UplinkItemName.Text = itemName;
+ UplinkItemDescription.SetMessage(itemDescription);
+
+ UplinkItemBuyButtonProtected.Text = $"{itemPrice} TC";
+ UplinkItemBuyButtonProtected.Disabled = !canBuy;
+ }
+ }
+}
diff --git a/Content.Client/Traitor/Uplink/UplinkMenu.xaml b/Content.Client/Traitor/Uplink/UplinkMenu.xaml
index 1694bc568c..43c6610f83 100644
--- a/Content.Client/Traitor/Uplink/UplinkMenu.xaml
+++ b/Content.Client/Traitor/Uplink/UplinkMenu.xaml
@@ -1,18 +1,22 @@
-
-
+
+
+
-
@@ -23,20 +27,21 @@
-
-
+
diff --git a/Content.Client/Traitor/Uplink/UplinkMenu.xaml.cs b/Content.Client/Traitor/Uplink/UplinkMenu.xaml.cs
index 5908c3efa1..f39644feff 100644
--- a/Content.Client/Traitor/Uplink/UplinkMenu.xaml.cs
+++ b/Content.Client/Traitor/Uplink/UplinkMenu.xaml.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using Content.Shared.PDA;
using Content.Shared.Traitor.Uplink;
using Robust.Client.AutoGenerated;
@@ -58,71 +58,17 @@ namespace Content.Client.Traitor.Uplink
{
return;
}
- var weightedColor = listing.Price switch
- {
- <= 0 => Color.Gray,
- <= 5 => Color.Green,
- <= 10 => Color.Yellow,
- <= 20 => Color.Orange,
- <= 50 => Color.Purple,
- _ => Color.Gray
- };
- var itemLabel = new Label
- {
- Text = listing.ListingName == string.Empty ? prototype.Name : listing.ListingName,
- ToolTip = listing.Description == string.Empty ? prototype.Description : listing.Description,
- HorizontalExpand = true,
- Modulate = _loggedInUplinkAccount?.DataBalance >= listing.Price
- ? Color.White
- : Color.Gray.WithAlpha(0.30f)
- };
- var priceLabel = new Label
- {
- Text = $"{listing.Price} TC",
- HorizontalAlignment = HAlignment.Right,
- Modulate = _loggedInUplinkAccount?.DataBalance >= listing.Price
- ? weightedColor
- : Color.Gray.WithAlpha(0.30f)
- };
+ var listingName = listing.ListingName == string.Empty ? prototype.Name : listing.ListingName;
+ var listingDesc = listing.Description == string.Empty ? prototype.Description : listing.Description;
+ var listingPrice = listing.Price;
+ var canBuy = _loggedInUplinkAccount?.DataBalance >= listing.Price;
- //Padding for the price lable.
- var pricePadding = new BoxContainer
- {
- Orientation = BoxContainer.LayoutOrientation.Horizontal,
- MinSize = (32, 1),
- };
+ var newListing = new UplinkListingControl(listingName, listingDesc, listingPrice, canBuy);
+ newListing.UplinkItemBuyButton.OnButtonDown += args
+ => OnListingButtonPressed?.Invoke(args, listing);
- //Contains the name of the item and its price. Used for spacing item name and price.
- var listingButtonHbox = new BoxContainer
- {
- Orientation = BoxContainer.LayoutOrientation.Horizontal,
- Children =
- {
- itemLabel,
- priceLabel,
- pricePadding
- }
- };
-
- var listingButtonPanelContainer = new PanelContainer
- {
- Children =
- {
- listingButtonHbox
- }
- };
-
- var pdaUplinkListingButton = new PDAUplinkItemButton(listing)
- {
- Children =
- {
- listingButtonPanelContainer
- }
- };
- pdaUplinkListingButton.OnPressed += args
- => OnListingButtonPressed?.Invoke(args, pdaUplinkListingButton.ButtonListing);
- UplinkListingsContainer.AddChild(pdaUplinkListingButton);
+ UplinkListingsContainer.AddChild(newListing);
}
public void ClearListings()
@@ -148,16 +94,6 @@ namespace Content.Client.Traitor.Uplink
}
}
- private sealed class PDAUplinkItemButton : ContainerButton
- {
- public PDAUplinkItemButton(UplinkListingData data)
- {
- ButtonListing = data;
- }
-
- public UplinkListingData ButtonListing { get; }
- }
-
private sealed class PDAUplinkCategoryButton : Button
{
public UplinkCategory ButtonCategory;
diff --git a/Content.Server/Traitor/Uplink/UplinkComponent.cs b/Content.Server/Traitor/Uplink/UplinkComponent.cs
index b686abb158..c189e415ea 100644
--- a/Content.Server/Traitor/Uplink/UplinkComponent.cs
+++ b/Content.Server/Traitor/Uplink/UplinkComponent.cs
@@ -3,6 +3,7 @@ using Content.Shared.Traitor.Uplink;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.ViewVariables;
+using System;
namespace Content.Server.Traitor.Uplink.Components
{
@@ -19,6 +20,20 @@ namespace Content.Server.Traitor.Uplink.Components
[DataField("insufficientFundsSound")]
public SoundSpecifier InsufficientFundsSound = new SoundPathSpecifier("/Audio/Effects/error.ogg");
+ [DataField("activatesInHands")]
+ public bool ActivatesInHands = false;
+
+ [DataField("presetInfo")]
+ public PresetUplinkInfo? PresetInfo = null;
+
[ViewVariables] public UplinkAccount? UplinkAccount;
+
+ [Serializable]
+ [DataDefinition]
+ public class PresetUplinkInfo
+ {
+ [DataField("balance")]
+ public int StartingBalance;
+ }
}
}
diff --git a/Content.Server/Traitor/Uplink/UplinkSystem.cs b/Content.Server/Traitor/Uplink/UplinkSystem.cs
index c0e028cc2a..9f6e9517f6 100644
--- a/Content.Server/Traitor/Uplink/UplinkSystem.cs
+++ b/Content.Server/Traitor/Uplink/UplinkSystem.cs
@@ -1,10 +1,12 @@
using Content.Server.Hands.Components;
using Content.Server.Inventory.Components;
using Content.Server.Items;
+using Content.Server.Mind.Components;
using Content.Server.PDA;
using Content.Server.Traitor.Uplink.Account;
using Content.Server.Traitor.Uplink.Components;
using Content.Server.UserInterface;
+using Content.Shared.Interaction;
using Content.Shared.Traitor.Uplink;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -31,6 +33,7 @@ namespace Content.Server.Traitor.Uplink
SubscribeLocalEvent(OnInit);
SubscribeLocalEvent(OnRemove);
+ SubscribeLocalEvent(OnUseHand);
SubscribeLocalEvent(OnBuy);
SubscribeLocalEvent(OnRequestUpdateUI);
@@ -51,6 +54,15 @@ namespace Content.Server.Traitor.Uplink
private void OnInit(EntityUid uid, UplinkComponent component, ComponentInit args)
{
RaiseLocalEvent(uid, new UplinkInitEvent(component));
+
+ // if component has a preset info (probably spawn by admin)
+ // create a new account and register it for this uplink
+ if (component.PresetInfo != null)
+ {
+ var account = new UplinkAccount(component.PresetInfo.StartingBalance);
+ _accounts.AddNewAccount(account);
+ SetAccount(component, account);
+ }
}
private void OnRemove(EntityUid uid, UplinkComponent component, ComponentRemove args)
@@ -58,6 +70,24 @@ namespace Content.Server.Traitor.Uplink
RaiseLocalEvent(uid, new UplinkRemovedEvent());
}
+ private void OnUseHand(EntityUid uid, UplinkComponent component, UseInHandEvent args)
+ {
+ if (args.Handled)
+ return;
+
+ // check if uplinks activates directly or use some proxy, like a PDA
+ if (!component.ActivatesInHands)
+ return;
+ if (component.UplinkAccount == null)
+ return;
+
+ if (!EntityManager.TryGetComponent(args.User.Uid, out ActorComponent? actor))
+ return;
+
+ ToggleUplinkUI(component, actor.PlayerSession);
+ args.Handled = true;
+ }
+
private void OnBalanceChangedBroadcast(UplinkAccountBalanceChanged ev)
{
foreach (var uplink in EntityManager.EntityQuery())
diff --git a/Resources/Locale/en-US/traitor/uplink/uplink-component.ftl b/Resources/Locale/en-US/traitor/uplink/uplink-component.ftl
index 61be32ed66..b02847b903 100644
--- a/Resources/Locale/en-US/traitor/uplink/uplink-component.ftl
+++ b/Resources/Locale/en-US/traitor/uplink/uplink-component.ftl
@@ -1,3 +1,7 @@
uplink-bound-user-interface-insufficient-funds-popup = Insufficient funds!
-uplink-bound-user-interface-tc-balance-popup = TC Balance: [color={$weightedColor}]{$balance}[/color]
\ No newline at end of file
+uplink-bound-user-interface-tc-balance-popup = TC Balance: [color={$weightedColor}]{$balance}[/color]
+
+uplink-user-interface-title = Uplink
+
+uplink-user-interface-search-label = Search
\ No newline at end of file
diff --git a/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml b/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml
index 1738695b6f..485e213e88 100644
--- a/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml
+++ b/Resources/Prototypes/Entities/Objects/Specific/syndicate.yml
@@ -2,7 +2,7 @@
name: telecrystal
parent: BaseItem
id: Telecrystal
- suffix: Twenty
+ suffix: 20 TC
description: It seems to be pulsing with suspiciously enticing energies.
components:
- type: Sprite
@@ -20,7 +20,7 @@
- type: entity
parent: Telecrystal
id: Telecrystal1
- suffix: Single
+ suffix: 1 TC
components:
- type: Stack
count: 1
@@ -28,7 +28,7 @@
- type: entity
parent: Telecrystal
id: Telecrystal5
- suffix: Five
+ suffix: 5 TC
components:
- type: Stack
count: 5
@@ -36,7 +36,48 @@
- type: entity
parent: Telecrystal
id: Telecrystal10
- suffix: Ten
+ suffix: 10 TC
components:
- type: Stack
count: 10
+
+# Uplinks
+- type: entity
+ parent: BaseItem
+ id: BaseUplinkRadio
+ name: syndicate uplink
+ description: Suspiciously looking old radio...
+ suffix: Empty
+ components:
+ - type: Sprite
+ sprite: Objects/Devices/communication.rsi
+ layers:
+ - state: old-radio
+ netsync: false
+ - type: Item
+ sprite: Objects/Devices/communication.rsi
+ HeldPrefix: old-radio
+ - type: UserInterface
+ interfaces:
+ - key: enum.UplinkUiKey.Key
+ type: UplinkBoundUserInterface
+ - type: Uplink
+ activatesInHands: true
+
+- type: entity
+ parent: BaseUplinkRadio
+ id: BaseUplinkRadio20TC
+ suffix: 20 TC
+ components:
+ - type: Uplink
+ presetInfo:
+ balance: 20
+
+- type: entity
+ parent: BaseUplinkRadio
+ id: BaseUplinkRadioDebug
+ suffix: Debug
+ components:
+ - type: Uplink
+ presetInfo:
+ balance: 9999
diff --git a/Resources/Textures/Objects/Devices/communication.rsi/meta.json b/Resources/Textures/Objects/Devices/communication.rsi/meta.json
index bf44d0c05b..6b1a633585 100644
--- a/Resources/Textures/Objects/Devices/communication.rsi/meta.json
+++ b/Resources/Textures/Objects/Devices/communication.rsi/meta.json
@@ -65,6 +65,17 @@
{
"name": "off-walkietalkie-inhand-left",
"directions": 4
+ },
+ {
+ "name": "old-radio"
+ },
+ {
+ "name": "old-radio-inhand-left",
+ "directions": 4
+ },
+ {
+ "name": "old-radio-inhand-right",
+ "directions": 4
}
]
}
diff --git a/Resources/Textures/Objects/Devices/communication.rsi/old-radio-inhand-left.png b/Resources/Textures/Objects/Devices/communication.rsi/old-radio-inhand-left.png
new file mode 100644
index 0000000000..e1cb184a79
Binary files /dev/null and b/Resources/Textures/Objects/Devices/communication.rsi/old-radio-inhand-left.png differ
diff --git a/Resources/Textures/Objects/Devices/communication.rsi/old-radio-inhand-right.png b/Resources/Textures/Objects/Devices/communication.rsi/old-radio-inhand-right.png
new file mode 100644
index 0000000000..ac3ef8ab79
Binary files /dev/null and b/Resources/Textures/Objects/Devices/communication.rsi/old-radio-inhand-right.png differ
diff --git a/Resources/Textures/Objects/Devices/communication.rsi/old-radio.png b/Resources/Textures/Objects/Devices/communication.rsi/old-radio.png
new file mode 100644
index 0000000000..23315c58a2
Binary files /dev/null and b/Resources/Textures/Objects/Devices/communication.rsi/old-radio.png differ