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"
|
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"
|
MinSize="512 512"
|
||||||
SetSize="512 512">
|
SetSize="512 512">
|
||||||
<BoxContainer Orientation="Vertical">
|
<BoxContainer Orientation="Vertical">
|
||||||
<BoxContainer Orientation="Vertical"
|
<BoxContainer Orientation="Vertical"
|
||||||
VerticalExpand="True">
|
VerticalExpand="True">
|
||||||
<RichTextLabel Name="BalanceInfoProtected"
|
<BoxContainer Orientation="Horizontal"
|
||||||
HorizontalAlignment="Center" />
|
Margin="4 4 4 4">
|
||||||
|
<RichTextLabel Name="BalanceInfoProtected"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
HorizontalAlignment="Left" />
|
||||||
|
</BoxContainer>
|
||||||
<PanelContainer VerticalExpand="True">
|
<PanelContainer VerticalExpand="True">
|
||||||
<PanelContainer.PanelOverride>
|
<PanelContainer.PanelOverride>
|
||||||
<gfx:StyleBoxFlat BackgroundColor="#000000FF" />
|
<gfx:StyleBoxFlat BackgroundColor="#000000FF" />
|
||||||
</PanelContainer.PanelOverride>
|
</PanelContainer.PanelOverride>
|
||||||
<SplitContainer Orientation="Horizontal"
|
<BoxContainer Orientation="Horizontal"
|
||||||
VerticalExpand="True">
|
VerticalExpand="True">
|
||||||
<PanelContainer VerticalExpand="True">
|
<PanelContainer VerticalExpand="True">
|
||||||
<PanelContainer.PanelOverride>
|
<PanelContainer.PanelOverride>
|
||||||
@@ -23,20 +27,21 @@
|
|||||||
<!-- Category buttons are added here by code -->
|
<!-- Category buttons are added here by code -->
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
<ScrollContainer HorizontalExpand="True"
|
<ScrollContainer Name="UplinkListingsScroll"
|
||||||
|
HorizontalExpand="True"
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
SizeFlagsStretchRatio="2"
|
SizeFlagsStretchRatio="2"
|
||||||
|
HScrollEnabled="False"
|
||||||
MinSize="100 256">
|
MinSize="100 256">
|
||||||
<BoxContainer Name="UplinkListingsContainer"
|
<BoxContainer Name="UplinkListingsContainer"
|
||||||
Orientation="Vertical"
|
Orientation="Vertical"
|
||||||
HorizontalExpand="True"
|
|
||||||
VerticalExpand="True"
|
VerticalExpand="True"
|
||||||
SizeFlagsStretchRatio="2"
|
SizeFlagsStretchRatio="2"
|
||||||
MinSize="100 256">
|
MinSize="100 256">
|
||||||
<!-- Listings are added here by code -->
|
<!-- Listings are added here by code -->
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</ScrollContainer>
|
</ScrollContainer>
|
||||||
</SplitContainer>
|
</BoxContainer>
|
||||||
</PanelContainer>
|
</PanelContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
@@ -58,71 +58,17 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
{
|
{
|
||||||
return;
|
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
|
var listingName = listing.ListingName == string.Empty ? prototype.Name : listing.ListingName;
|
||||||
{
|
var listingDesc = listing.Description == string.Empty ? prototype.Description : listing.Description;
|
||||||
Text = $"{listing.Price} TC",
|
var listingPrice = listing.Price;
|
||||||
HorizontalAlignment = HAlignment.Right,
|
var canBuy = _loggedInUplinkAccount?.DataBalance >= listing.Price;
|
||||||
Modulate = _loggedInUplinkAccount?.DataBalance >= listing.Price
|
|
||||||
? weightedColor
|
|
||||||
: Color.Gray.WithAlpha(0.30f)
|
|
||||||
};
|
|
||||||
|
|
||||||
//Padding for the price lable.
|
var newListing = new UplinkListingControl(listingName, listingDesc, listingPrice, canBuy);
|
||||||
var pricePadding = new BoxContainer
|
newListing.UplinkItemBuyButton.OnButtonDown += args
|
||||||
{
|
=> OnListingButtonPressed?.Invoke(args, listing);
|
||||||
Orientation = BoxContainer.LayoutOrientation.Horizontal,
|
|
||||||
MinSize = (32, 1),
|
|
||||||
};
|
|
||||||
|
|
||||||
//Contains the name of the item and its price. Used for spacing item name and price.
|
UplinkListingsContainer.AddChild(newListing);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearListings()
|
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
|
private sealed class PDAUplinkCategoryButton : Button
|
||||||
{
|
{
|
||||||
public UplinkCategory ButtonCategory;
|
public UplinkCategory ButtonCategory;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using Content.Shared.Traitor.Uplink;
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace Content.Server.Traitor.Uplink.Components
|
namespace Content.Server.Traitor.Uplink.Components
|
||||||
{
|
{
|
||||||
@@ -19,6 +20,20 @@ namespace Content.Server.Traitor.Uplink.Components
|
|||||||
[DataField("insufficientFundsSound")]
|
[DataField("insufficientFundsSound")]
|
||||||
public SoundSpecifier InsufficientFundsSound = new SoundPathSpecifier("/Audio/Effects/error.ogg");
|
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;
|
[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.Hands.Components;
|
||||||
using Content.Server.Inventory.Components;
|
using Content.Server.Inventory.Components;
|
||||||
using Content.Server.Items;
|
using Content.Server.Items;
|
||||||
|
using Content.Server.Mind.Components;
|
||||||
using Content.Server.PDA;
|
using Content.Server.PDA;
|
||||||
using Content.Server.Traitor.Uplink.Account;
|
using Content.Server.Traitor.Uplink.Account;
|
||||||
using Content.Server.Traitor.Uplink.Components;
|
using Content.Server.Traitor.Uplink.Components;
|
||||||
using Content.Server.UserInterface;
|
using Content.Server.UserInterface;
|
||||||
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
using Robust.Server.Player;
|
using Robust.Server.Player;
|
||||||
@@ -31,6 +33,7 @@ namespace Content.Server.Traitor.Uplink
|
|||||||
|
|
||||||
SubscribeLocalEvent<UplinkComponent, ComponentInit>(OnInit);
|
SubscribeLocalEvent<UplinkComponent, ComponentInit>(OnInit);
|
||||||
SubscribeLocalEvent<UplinkComponent, ComponentRemove>(OnRemove);
|
SubscribeLocalEvent<UplinkComponent, ComponentRemove>(OnRemove);
|
||||||
|
SubscribeLocalEvent<UplinkComponent, UseInHandEvent>(OnUseHand);
|
||||||
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy);
|
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy);
|
||||||
SubscribeLocalEvent<UplinkComponent, UplinkRequestUpdateInterfaceMessage>(OnRequestUpdateUI);
|
SubscribeLocalEvent<UplinkComponent, UplinkRequestUpdateInterfaceMessage>(OnRequestUpdateUI);
|
||||||
|
|
||||||
@@ -51,6 +54,15 @@ namespace Content.Server.Traitor.Uplink
|
|||||||
private void OnInit(EntityUid uid, UplinkComponent component, ComponentInit args)
|
private void OnInit(EntityUid uid, UplinkComponent component, ComponentInit args)
|
||||||
{
|
{
|
||||||
RaiseLocalEvent(uid, new UplinkInitEvent(component));
|
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)
|
private void OnRemove(EntityUid uid, UplinkComponent component, ComponentRemove args)
|
||||||
@@ -58,6 +70,24 @@ namespace Content.Server.Traitor.Uplink
|
|||||||
RaiseLocalEvent(uid, new UplinkRemovedEvent());
|
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)
|
private void OnBalanceChangedBroadcast(UplinkAccountBalanceChanged ev)
|
||||||
{
|
{
|
||||||
foreach (var uplink in EntityManager.EntityQuery<UplinkComponent>())
|
foreach (var uplink in EntityManager.EntityQuery<UplinkComponent>())
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
uplink-bound-user-interface-insufficient-funds-popup = Insufficient funds!
|
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
|
name: telecrystal
|
||||||
parent: BaseItem
|
parent: BaseItem
|
||||||
id: Telecrystal
|
id: Telecrystal
|
||||||
suffix: Twenty
|
suffix: 20 TC
|
||||||
description: It seems to be pulsing with suspiciously enticing energies.
|
description: It seems to be pulsing with suspiciously enticing energies.
|
||||||
components:
|
components:
|
||||||
- type: Sprite
|
- type: Sprite
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: Telecrystal
|
parent: Telecrystal
|
||||||
id: Telecrystal1
|
id: Telecrystal1
|
||||||
suffix: Single
|
suffix: 1 TC
|
||||||
components:
|
components:
|
||||||
- type: Stack
|
- type: Stack
|
||||||
count: 1
|
count: 1
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: Telecrystal
|
parent: Telecrystal
|
||||||
id: Telecrystal5
|
id: Telecrystal5
|
||||||
suffix: Five
|
suffix: 5 TC
|
||||||
components:
|
components:
|
||||||
- type: Stack
|
- type: Stack
|
||||||
count: 5
|
count: 5
|
||||||
@@ -36,7 +36,48 @@
|
|||||||
- type: entity
|
- type: entity
|
||||||
parent: Telecrystal
|
parent: Telecrystal
|
||||||
id: Telecrystal10
|
id: Telecrystal10
|
||||||
suffix: Ten
|
suffix: 10 TC
|
||||||
components:
|
components:
|
||||||
- type: Stack
|
- type: Stack
|
||||||
count: 10
|
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",
|
"name": "off-walkietalkie-inhand-left",
|
||||||
"directions": 4
|
"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