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:
Alex Evgrashin
2021-10-15 13:49:59 +03:00
committed by GitHub
parent 278f878d73
commit ce0b73ef62
12 changed files with 167 additions and 86 deletions

View File

@@ -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;