Implement Cargo Console (#413)
* Implement Cargo Console Add to CargoConsoleComponent GalacticBank information for syncing Bank Account Balance. Implement CargoOrderDatabase on the server side and a list of orders in the CargoOrderDatabaseComponent on the client side. This makes it easier to change data on the server side but also utilize the state syncing between components. Implement GalacticMarketComponent. Only productIds get sent. Both client and server create their lists from YAML. Implement basic spawning of items from approved orders in CargoOrderDatabase. * Finish Cargo Console Add validation to make sure Order Amount is one or more. Implement approve and cancel buttons to CargoConsoleMenu orders list row. Add price to CargoConsoleMenu product list row. Implement CargoOrderDataManager to consolidate CargoOrder lists. Refactor CargoOrderDatabaseComponent to use CargoOrderDataManager instead of storing duplicate lists. Implement canceling orders. Implement approving orders. Fix sprite links. Implement Cargo Request Console.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
58709d2d26
commit
1580750606
465
Content.Client/UserInterface/Cargo/CargoConsoleMenu.cs
Normal file
465
Content.Client/UserInterface/Cargo/CargoConsoleMenu.cs
Normal file
@@ -0,0 +1,465 @@
|
||||
using Content.Client.GameObjects.Components.Cargo;
|
||||
using Content.Shared.Prototypes.Cargo;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.Interfaces.ResourceManagement;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.Utility;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.Utility;
|
||||
|
||||
namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
public class CargoConsoleMenu : SS14Window
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ILocalizationManager _loc;
|
||||
[Dependency] private readonly IResourceCache _resourceCache;
|
||||
#pragma warning restore 649
|
||||
|
||||
protected override Vector2? CustomSize => (400, 600);
|
||||
|
||||
public CargoConsoleBoundUserInterface Owner { get; private set; }
|
||||
|
||||
public event Action<BaseButton.ButtonEventArgs> OnItemSelected;
|
||||
public event Action<BaseButton.ButtonEventArgs> OnOrderApproved;
|
||||
public event Action<BaseButton.ButtonEventArgs> OnOrderCanceled;
|
||||
|
||||
private List<string> _categoryStrings = new List<string>();
|
||||
|
||||
private Label _accountNameLabel { get; set; }
|
||||
private Label _pointsLabel { get; set; }
|
||||
private Label _shuttleStatusLabel { get; set; }
|
||||
private VBoxContainer _requests { get; set; }
|
||||
private VBoxContainer _orders { get; set; }
|
||||
private OptionButton _categories { get; set; }
|
||||
private LineEdit _searchBar { get; set; }
|
||||
|
||||
public VBoxContainer Products { get; set; }
|
||||
public Button CallShuttleButton { get; set; }
|
||||
public Button PermissionsButton { get; set; }
|
||||
|
||||
private string _category = null;
|
||||
|
||||
public CargoConsoleMenu(CargoConsoleBoundUserInterface owner)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
Owner = owner;
|
||||
|
||||
if (Owner.RequestOnly)
|
||||
Title = _loc.GetString("Cargo Request Console");
|
||||
else
|
||||
Title = _loc.GetString("Cargo Shuttle Console");
|
||||
|
||||
var rows = new VBoxContainer
|
||||
{
|
||||
MarginTop = 0
|
||||
};
|
||||
|
||||
var accountName = new HBoxContainer()
|
||||
{
|
||||
MarginTop = 0
|
||||
};
|
||||
var accountNameLabel = new Label {
|
||||
Text = _loc.GetString("Account Name: "),
|
||||
StyleClasses = { NanoStyle.StyleClassLabelKeyText }
|
||||
};
|
||||
_accountNameLabel = new Label {
|
||||
Text = "None" //Owner.Bank.Account.Name
|
||||
};
|
||||
accountName.AddChild(accountNameLabel);
|
||||
accountName.AddChild(_accountNameLabel);
|
||||
rows.AddChild(accountName);
|
||||
|
||||
var points = new HBoxContainer();
|
||||
var pointsLabel = new Label
|
||||
{
|
||||
Text = _loc.GetString("Points: "),
|
||||
StyleClasses = { NanoStyle.StyleClassLabelKeyText }
|
||||
};
|
||||
_pointsLabel = new Label
|
||||
{
|
||||
Text = "0" //Owner.Bank.Account.Balance.ToString()
|
||||
};
|
||||
points.AddChild(pointsLabel);
|
||||
points.AddChild(_pointsLabel);
|
||||
rows.AddChild(points);
|
||||
|
||||
var shuttleStatus = new HBoxContainer();
|
||||
var shuttleStatusLabel = new Label
|
||||
{
|
||||
Text = _loc.GetString("Shuttle Status: "),
|
||||
StyleClasses = { NanoStyle.StyleClassLabelKeyText }
|
||||
};
|
||||
_shuttleStatusLabel = new Label
|
||||
{
|
||||
Text = _loc.GetString("Away") // Shuttle.Status
|
||||
};
|
||||
shuttleStatus.AddChild(shuttleStatusLabel);
|
||||
shuttleStatus.AddChild(_shuttleStatusLabel);
|
||||
rows.AddChild(shuttleStatus);
|
||||
|
||||
var buttons = new HBoxContainer();
|
||||
CallShuttleButton = new Button()
|
||||
{
|
||||
Text = _loc.GetString("Call Shuttle"),
|
||||
TextAlign = Button.AlignMode.Center,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
};
|
||||
PermissionsButton = new Button()
|
||||
{
|
||||
Text = _loc.GetString("Permissions"),
|
||||
TextAlign = Button.AlignMode.Center
|
||||
};
|
||||
buttons.AddChild(CallShuttleButton);
|
||||
buttons.AddChild(PermissionsButton);
|
||||
rows.AddChild(buttons);
|
||||
|
||||
var category = new HBoxContainer();
|
||||
_categories = new OptionButton
|
||||
{
|
||||
Prefix = _loc.GetString("Categories: "),
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1
|
||||
};
|
||||
_searchBar = new LineEdit
|
||||
{
|
||||
PlaceHolder = _loc.GetString("Search"),
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1
|
||||
};
|
||||
category.AddChild(_categories);
|
||||
category.AddChild(_searchBar);
|
||||
rows.AddChild(category);
|
||||
|
||||
var products = new ScrollContainer()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 6
|
||||
};
|
||||
Products = new VBoxContainer()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
products.AddChild(Products);
|
||||
rows.AddChild(products);
|
||||
|
||||
var requestsAndOrders = new PanelContainer
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 6,
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.Black }
|
||||
};
|
||||
var orderScrollBox = new ScrollContainer
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
var rAndOVBox = new VBoxContainer();
|
||||
var requestsLabel = new Label { Text = _loc.GetString("Requests") };
|
||||
_requests = new VBoxContainer // replace with scroll box so that approval buttons can be added
|
||||
{
|
||||
StyleClasses = { "transparentItemList" },
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
};
|
||||
var ordersLabel = new Label { Text = _loc.GetString("Orders") };
|
||||
_orders = new VBoxContainer
|
||||
{
|
||||
StyleClasses = { "transparentItemList" },
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsStretchRatio = 1,
|
||||
};
|
||||
rAndOVBox.AddChild(requestsLabel);
|
||||
rAndOVBox.AddChild(_requests);
|
||||
rAndOVBox.AddChild(ordersLabel);
|
||||
rAndOVBox.AddChild(_orders);
|
||||
orderScrollBox.AddChild(rAndOVBox);
|
||||
requestsAndOrders.AddChild(orderScrollBox);
|
||||
rows.AddChild(requestsAndOrders);
|
||||
|
||||
rows.AddChild(new TextureButton
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
});
|
||||
Contents.AddChild(rows);
|
||||
|
||||
CallShuttleButton.OnPressed += OnCallShuttleButtonPressed;
|
||||
_searchBar.OnTextChanged += OnSearchBarTextChanged;
|
||||
_categories.OnItemSelected += OnCategoryItemSelected;
|
||||
}
|
||||
|
||||
private void OnCallShuttleButtonPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
}
|
||||
|
||||
private void OnCategoryItemSelected(OptionButton.ItemSelectedEventArgs args)
|
||||
{
|
||||
SetCategoryText(args.Id);
|
||||
PopulateProducts();
|
||||
}
|
||||
|
||||
private void OnSearchBarTextChanged(LineEdit.LineEditEventArgs args)
|
||||
{
|
||||
PopulateProducts();
|
||||
}
|
||||
|
||||
private void SetCategoryText(int id)
|
||||
{
|
||||
if (id == 0)
|
||||
_category = null;
|
||||
else
|
||||
_category = _categoryStrings[id];
|
||||
_categories.SelectId(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populates the list of products that will actually be shown, using the current filters.
|
||||
/// </summary>
|
||||
public void PopulateProducts()
|
||||
{
|
||||
Products.RemoveAllChildren();
|
||||
|
||||
var search = _searchBar.Text.Trim().ToLowerInvariant();
|
||||
foreach (var prototype in Owner.Market.Products)
|
||||
{
|
||||
// if no search or category
|
||||
// else if search
|
||||
// else if category and not search
|
||||
if ((search.Length == 0 && _category == null) ||
|
||||
(search.Length != 0 && prototype.Name.ToLowerInvariant().Contains(search)) ||
|
||||
(search.Length == 0 && _category != null && prototype.Category.Equals(_category)))
|
||||
{
|
||||
var button = new CargoProductRow();
|
||||
button.Product = prototype;
|
||||
button.ProductName.Text = prototype.Name;
|
||||
button.PointCost.Text = prototype.PointCost.ToString();
|
||||
button.Icon.Texture = prototype.Icon.Frame0();
|
||||
button.MainButton.OnPressed += (args) =>
|
||||
{
|
||||
OnItemSelected?.Invoke(args);
|
||||
};
|
||||
Products.AddChild(button);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populates the list of products that will actually be shown, using the current filters.
|
||||
/// </summary>
|
||||
public void PopulateCategories()
|
||||
{
|
||||
_categoryStrings.Clear();
|
||||
_categories.Clear();
|
||||
|
||||
_categoryStrings.Add(_loc.GetString("All"));
|
||||
|
||||
var search = _searchBar.Text.Trim().ToLowerInvariant();
|
||||
foreach (var prototype in Owner.Market.Products)
|
||||
{
|
||||
if (!_categoryStrings.Contains(prototype.Category))
|
||||
{
|
||||
_categoryStrings.Add(_loc.GetString(prototype.Category));
|
||||
}
|
||||
}
|
||||
_categoryStrings.Sort();
|
||||
foreach (var str in _categoryStrings)
|
||||
{
|
||||
_categories.AddItem(str);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Populates the list of orders and requests.
|
||||
/// </summary>
|
||||
public void PopulateOrders()
|
||||
{
|
||||
_orders.RemoveAllChildren();
|
||||
_requests.RemoveAllChildren();
|
||||
|
||||
foreach (var order in Owner.Orders.Orders)
|
||||
{
|
||||
var row = new CargoOrderRow();
|
||||
row.Order = order;
|
||||
row.Icon.Texture = Owner.Market.GetProduct(order.ProductId).Icon.Frame0();
|
||||
row.ProductName.Text = $"{Owner.Market.GetProduct(order.ProductId).Name} (x{order.Amount}) by {order.Requester}";
|
||||
row.Description.Text = $"Reasons: {order.Reason}";
|
||||
row.Cancel.OnPressed += (args) => { OnOrderCanceled?.Invoke(args); };
|
||||
if (order.Approved)
|
||||
{
|
||||
row.Approve.Visible = false;
|
||||
row.Cancel.Visible = false;
|
||||
_orders.AddChild(row);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Owner.RequestOnly)
|
||||
row.Approve.Visible = false;
|
||||
else
|
||||
row.Approve.OnPressed += (args) => { OnOrderApproved?.Invoke(args); };
|
||||
_requests.AddChild(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Populate()
|
||||
{
|
||||
PopulateProducts();
|
||||
PopulateCategories();
|
||||
PopulateOrders();
|
||||
}
|
||||
|
||||
public void UpdateBankData()
|
||||
{
|
||||
_accountNameLabel.Text = Owner.BankName;
|
||||
_pointsLabel.Text = Owner.BankBalance.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Show/Hide Call Shuttle button and Approve buttons
|
||||
/// </summary>
|
||||
public void UpdateRequestOnly()
|
||||
{
|
||||
CallShuttleButton.Visible = !Owner.RequestOnly;
|
||||
foreach (CargoOrderRow row in _requests.Children)
|
||||
{
|
||||
row.Approve.Visible = !Owner.RequestOnly;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal class CargoProductRow : PanelContainer
|
||||
{
|
||||
public CargoProductPrototype Product { get; set; }
|
||||
public TextureRect Icon { get; private set; }
|
||||
public Button MainButton { get; private set; }
|
||||
public Label ProductName { get; private set; }
|
||||
public Label PointCost { get; private set; }
|
||||
|
||||
public CargoProductRow()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand;
|
||||
|
||||
MainButton = new Button
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
AddChild(MainButton);
|
||||
|
||||
var hBox = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
|
||||
Icon = new TextureRect
|
||||
{
|
||||
CustomMinimumSize = new Vector2(32.0f, 32.0f),
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
RectClipContent = true
|
||||
};
|
||||
hBox.AddChild(Icon);
|
||||
|
||||
ProductName = new Label
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand
|
||||
};
|
||||
hBox.AddChild(ProductName);
|
||||
|
||||
var panel = new PanelContainer
|
||||
{
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = new Color(37, 37, 42) },
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
PointCost = new Label
|
||||
{
|
||||
CustomMinimumSize = new Vector2(40.0f, 32.0f),
|
||||
Align = Label.AlignMode.Right
|
||||
};
|
||||
panel.AddChild(PointCost);
|
||||
hBox.AddChild(panel);
|
||||
|
||||
AddChild(hBox);
|
||||
}
|
||||
}
|
||||
|
||||
internal class CargoOrderRow : PanelContainer
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] readonly IResourceCache _resourceCache;
|
||||
#pragma warning restore 649
|
||||
|
||||
public CargoOrderData Order { get; set; }
|
||||
public TextureRect Icon { get; private set; }
|
||||
public Label ProductName { get; private set; }
|
||||
public Label Description { get; private set; }
|
||||
public BaseButton Approve { get; private set; }
|
||||
public BaseButton Cancel { get; private set; }
|
||||
|
||||
public CargoOrderRow()
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand;
|
||||
|
||||
var hBox = new HBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
MouseFilter = MouseFilterMode.Ignore
|
||||
};
|
||||
|
||||
Icon = new TextureRect
|
||||
{
|
||||
CustomMinimumSize = new Vector2(32.0f, 32.0f),
|
||||
MouseFilter = MouseFilterMode.Ignore,
|
||||
RectClipContent = true
|
||||
};
|
||||
hBox.AddChild(Icon);
|
||||
|
||||
var vBox = new VBoxContainer
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
SizeFlagsVertical = SizeFlags.FillExpand
|
||||
};
|
||||
ProductName = new Label
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
StyleClasses = { NanoStyle.StyleClassLabelSubText },
|
||||
ClipText = true
|
||||
};
|
||||
Description = new Label
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
StyleClasses = { NanoStyle.StyleClassLabelSubText },
|
||||
ClipText = true
|
||||
};
|
||||
vBox.AddChild(ProductName);
|
||||
vBox.AddChild(Description);
|
||||
hBox.AddChild(vBox);
|
||||
|
||||
Approve = new Button
|
||||
{
|
||||
Text = "Approve",
|
||||
StyleClasses = { NanoStyle.StyleClassLabelSubText }
|
||||
};
|
||||
hBox.AddChild(Approve);
|
||||
|
||||
Cancel = new Button
|
||||
{
|
||||
Text = "Cancel",
|
||||
StyleClasses = { NanoStyle.StyleClassLabelSubText }
|
||||
};
|
||||
hBox.AddChild(Cancel);
|
||||
|
||||
AddChild(hBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
66
Content.Client/UserInterface/Cargo/CargoConsoleOrderMenu.cs
Normal file
66
Content.Client/UserInterface/Cargo/CargoConsoleOrderMenu.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
class CargoConsoleOrderMenu : SS14Window
|
||||
{
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ILocalizationManager _loc;
|
||||
#pragma warning restore 649
|
||||
|
||||
public LineEdit Requester { get; set; }
|
||||
public LineEdit Reason { get; set; }
|
||||
public SpinBox Amount { get; set; }
|
||||
public Button SubmitButton { get; set; }
|
||||
|
||||
public CargoConsoleOrderMenu()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Title = _loc.GetString("Order Form");
|
||||
|
||||
var vBox = new VBoxContainer();
|
||||
var gridContainer = new GridContainer { Columns = 2 };
|
||||
|
||||
var requesterLabel = new Label { Text = _loc.GetString("Name:") };
|
||||
Requester = new LineEdit();
|
||||
gridContainer.AddChild(requesterLabel);
|
||||
gridContainer.AddChild(Requester);
|
||||
|
||||
var reasonLabel = new Label { Text = _loc.GetString("Reason:") };
|
||||
Reason = new LineEdit();
|
||||
gridContainer.AddChild(reasonLabel);
|
||||
gridContainer.AddChild(Reason);
|
||||
|
||||
var amountLabel = new Label { Text = _loc.GetString("Amount:") };
|
||||
Amount = new SpinBox
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
Value = 1
|
||||
};
|
||||
Amount.SetButtons(new List<int>() { -100, -10, -1 }, new List<int>() { 1, 10, 100 });
|
||||
Amount.IsValid = (n) => {
|
||||
return (n > 0);
|
||||
};
|
||||
gridContainer.AddChild(amountLabel);
|
||||
gridContainer.AddChild(Amount);
|
||||
|
||||
vBox.AddChild(gridContainer);
|
||||
|
||||
SubmitButton = new Button()
|
||||
{
|
||||
Text = _loc.GetString("OK"),
|
||||
TextAlign = Button.AlignMode.Center,
|
||||
};
|
||||
vBox.AddChild(SubmitButton);
|
||||
|
||||
Contents.AddChild(vBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
|
||||
using Content.Client.GameObjects.Components.Cargo;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using System;
|
||||
using static Robust.Client.UserInterface.Controls.ItemList;
|
||||
|
||||
namespace Content.Client.UserInterface.Cargo
|
||||
{
|
||||
public class GalacticBankSelectionMenu : SS14Window
|
||||
{
|
||||
private ItemList _accounts;
|
||||
private int _accountCount = 0;
|
||||
private string[] _accountNames = new string[] { };
|
||||
private int[] _accountIds = new int[] { };
|
||||
private int _selectedAccountId = -1;
|
||||
|
||||
#pragma warning disable 649
|
||||
[Dependency] private readonly ILocalizationManager _loc;
|
||||
#pragma warning restore 649
|
||||
|
||||
protected override Vector2? CustomSize => (300, 300);
|
||||
|
||||
public CargoConsoleBoundUserInterface Owner;
|
||||
|
||||
public GalacticBankSelectionMenu()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Title = _loc.GetString("Galactic Bank Selection");
|
||||
|
||||
_accounts = new ItemList() { SelectMode = ItemList.ItemListSelectMode.Single };
|
||||
|
||||
var margin = new MarginContainer()
|
||||
{
|
||||
SizeFlagsVertical = SizeFlags.FillExpand,
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
MarginTop = 5f,
|
||||
MarginLeft = 5f,
|
||||
MarginRight = -5f,
|
||||
MarginBottom = -5f,
|
||||
};
|
||||
|
||||
margin.AddChild(_accounts);
|
||||
|
||||
Contents.AddChild(margin);
|
||||
}
|
||||
|
||||
public void Populate(int accountCount, string[] accountNames, int[] accountIds, int selectedAccountId)
|
||||
{
|
||||
_accountCount = accountCount;
|
||||
_accountNames = accountNames;
|
||||
_accountIds = accountIds;
|
||||
_selectedAccountId = selectedAccountId;
|
||||
|
||||
_accounts.Clear();
|
||||
for (var i = 0; i < _accountCount; i++)
|
||||
{
|
||||
var id = _accountIds[i];
|
||||
_accounts.AddItem($"ID: {id} || {_accountNames[i]}");
|
||||
if (id == _selectedAccountId)
|
||||
_accounts[id].Selected = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace Content.Client.UserInterface
|
||||
public const string StyleClassLabelHeading = "LabelHeading";
|
||||
public const string StyleClassLabelHeadingBigger = "LabelHeadingBigger";
|
||||
public const string StyleClassLabelSubText = "LabelSubText";
|
||||
public const string StyleClassLabelKeyText = "LabelKeyText";
|
||||
public const string StyleClassLabelSecondaryColor = "LabelSecondaryColor";
|
||||
public const string StyleClassLabelBig = "LabelBig";
|
||||
public const string StyleClassButtonBig = "ButtonBig";
|
||||
@@ -36,6 +37,7 @@ namespace Content.Client.UserInterface
|
||||
var resCache = IoCManager.Resolve<IResourceCache>();
|
||||
var notoSans10 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 10);
|
||||
var notoSans12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 12);
|
||||
var notoSansBold12 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 12);
|
||||
var notoSansDisplayBold14 = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 14);
|
||||
var notoSans16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Regular.ttf", 16);
|
||||
var notoSansBold16 = resCache.GetFont("/Nano/NotoSans/NotoSans-Bold.ttf", 16);
|
||||
@@ -170,6 +172,9 @@ namespace Content.Client.UserInterface
|
||||
var itemListItemBackground = new StyleBoxFlat {BackgroundColor = new Color(55, 55, 68)};
|
||||
itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
|
||||
itemListItemBackground.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
|
||||
var itemListItemBackgroundTransparent = new StyleBoxFlat { BackgroundColor = Color.Transparent };
|
||||
itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Vertical, 2);
|
||||
itemListItemBackgroundTransparent.SetContentMarginOverride(StyleBox.Margin.Horizontal, 4);
|
||||
|
||||
// NanoHeading
|
||||
var nanoHeadingTex = resCache.GetTexture("/Nano/nanoheading.svg.96dpi.png");
|
||||
@@ -429,6 +434,18 @@ namespace Content.Client.UserInterface
|
||||
itemListBackgroundSelected)
|
||||
}),
|
||||
|
||||
new StyleRule(new SelectorElement(typeof(ItemList), new []{"transparentItemList"}, null, null), new[]
|
||||
{
|
||||
new StyleProperty(ItemList.StylePropertyBackground,
|
||||
new StyleBoxFlat {BackgroundColor = Color.Transparent}),
|
||||
new StyleProperty(ItemList.StylePropertyItemBackground,
|
||||
itemListItemBackgroundTransparent),
|
||||
new StyleProperty(ItemList.StylePropertyDisabledItemBackground,
|
||||
itemListItemBackgroundDisabled),
|
||||
new StyleProperty(ItemList.StylePropertySelectedItemBackground,
|
||||
itemListBackgroundSelected)
|
||||
}),
|
||||
|
||||
// Tree
|
||||
new StyleRule(new SelectorElement(typeof(Tree), null, null, null), new[]
|
||||
{
|
||||
@@ -475,12 +492,18 @@ namespace Content.Client.UserInterface
|
||||
new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
|
||||
}),
|
||||
|
||||
new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelSecondaryColor}, null, null),
|
||||
new[]
|
||||
{
|
||||
new StyleProperty(Label.StylePropertyFont, notoSans12),
|
||||
new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
|
||||
}),
|
||||
// Label Key
|
||||
new StyleRule(new SelectorElement(typeof(Label), new []{StyleClassLabelKeyText}, null, null), new []
|
||||
{
|
||||
new StyleProperty(Label.StylePropertyFont, notoSansBold12),
|
||||
new StyleProperty(Label.StylePropertyFontColor, NanoGold)
|
||||
}),
|
||||
|
||||
new StyleRule(new SelectorElement(typeof(Label), new[] {StyleClassLabelSecondaryColor}, null, null), new[]
|
||||
{
|
||||
new StyleProperty(Label.StylePropertyFont, notoSans12),
|
||||
new StyleProperty(Label.StylePropertyFontColor, Color.DarkGray),
|
||||
}),
|
||||
|
||||
// Big Button
|
||||
new StyleRule(new SelectorElement(typeof(Button), new[] {StyleClassButtonBig}, null, null), new[]
|
||||
|
||||
Reference in New Issue
Block a user