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

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

View 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;
}
}
}

View File

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

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;