Description for Uplink UI (and preset uplinks) (#4870)
* testing decription textlabel * Move uplink listing to a new menu * Add search bar * Added description * Added radio uplink * Added preset uplinks * Minor fix * Fixed comma
This commit is contained in:
14
Content.Client/Traitor/Uplink/UplinkListingControl.xaml
Normal file
14
Content.Client/Traitor/Uplink/UplinkListingControl.xaml
Normal file
@@ -0,0 +1,14 @@
|
||||
<Control xmlns="https://spacestation14.io">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
Margin="8 8 8 8">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Name="UplinkItemName"
|
||||
HorizontalExpand="True"/>
|
||||
<Button Name="UplinkItemBuyButtonProtected"
|
||||
HorizontalAlignment="Right"
|
||||
MinWidth="64"/>
|
||||
</BoxContainer>
|
||||
<PanelContainer StyleClasses="HighDivider" />
|
||||
<RichTextLabel Name="UplinkItemDescription" />
|
||||
</BoxContainer>
|
||||
</Control>
|
||||
25
Content.Client/Traitor/Uplink/UplinkListingControl.xaml.cs
Normal file
25
Content.Client/Traitor/Uplink/UplinkListingControl.xaml.cs
Normal file
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,22 @@
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
<SS14Window xmlns="https://spacestation14.io"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
Title="{Loc 'pda-bound-user-interface-uplink-tab-title'}"
|
||||
Title="{Loc 'uplink-user-interface-title'}"
|
||||
MinSize="512 512"
|
||||
SetSize="512 512">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Vertical"
|
||||
VerticalExpand="True">
|
||||
<RichTextLabel Name="BalanceInfoProtected"
|
||||
HorizontalAlignment="Center" />
|
||||
<BoxContainer Orientation="Horizontal"
|
||||
Margin="4 4 4 4">
|
||||
<RichTextLabel Name="BalanceInfoProtected"
|
||||
HorizontalExpand="True"
|
||||
HorizontalAlignment="Left" />
|
||||
</BoxContainer>
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="#000000FF" />
|
||||
</PanelContainer.PanelOverride>
|
||||
<SplitContainer Orientation="Horizontal"
|
||||
<BoxContainer Orientation="Horizontal"
|
||||
VerticalExpand="True">
|
||||
<PanelContainer VerticalExpand="True">
|
||||
<PanelContainer.PanelOverride>
|
||||
@@ -23,20 +27,21 @@
|
||||
<!-- Category buttons are added here by code -->
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
<ScrollContainer HorizontalExpand="True"
|
||||
<ScrollContainer Name="UplinkListingsScroll"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"
|
||||
SizeFlagsStretchRatio="2"
|
||||
HScrollEnabled="False"
|
||||
MinSize="100 256">
|
||||
<BoxContainer Name="UplinkListingsContainer"
|
||||
Orientation="Vertical"
|
||||
HorizontalExpand="True"
|
||||
VerticalExpand="True"
|
||||
SizeFlagsStretchRatio="2"
|
||||
MinSize="100 256">
|
||||
<!-- Listings are added here by code -->
|
||||
</BoxContainer>
|
||||
</ScrollContainer>
|
||||
</SplitContainer>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<UplinkComponent, ComponentInit>(OnInit);
|
||||
SubscribeLocalEvent<UplinkComponent, ComponentRemove>(OnRemove);
|
||||
SubscribeLocalEvent<UplinkComponent, UseInHandEvent>(OnUseHand);
|
||||
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy);
|
||||
SubscribeLocalEvent<UplinkComponent, UplinkRequestUpdateInterfaceMessage>(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<UplinkComponent>())
|
||||
|
||||
@@ -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]
|
||||
uplink-bound-user-interface-tc-balance-popup = TC Balance: [color={$weightedColor}]{$balance}[/color]
|
||||
|
||||
uplink-user-interface-title = Uplink
|
||||
|
||||
uplink-user-interface-search-label = Search
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 215 B |
Binary file not shown.
|
After Width: | Height: | Size: 243 B |
Binary file not shown.
|
After Width: | Height: | Size: 401 B |
Reference in New Issue
Block a user