Uplink UI icons and withdraw button (#4929)
* Uplink menu has icons now * Add item icons * Add few descriptions * Better withdraw window * Finished with withdraw window * Refactored withdraw ui and fix some bugs * Basic withdraw * Quick fixes * Removed uplink listing for TCs * Move slider to separate control * Final touches * A bit more * Not again... * Fixed names * Address review * Fixed robust * Non necessary check
This commit is contained in:
@@ -1,26 +1,14 @@
|
|||||||
using Content.Client.Examine;
|
|
||||||
using Content.Client.Message;
|
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.UserInterface;
|
|
||||||
using Robust.Client.UserInterface.Controls;
|
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Localization;
|
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Prototypes;
|
|
||||||
|
|
||||||
namespace Content.Client.Traitor.Uplink
|
namespace Content.Client.Traitor.Uplink
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[UsedImplicitly]
|
||||||
public class UplinkBoundUserInterface : BoundUserInterface
|
public class UplinkBoundUserInterface : BoundUserInterface
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
|
||||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
|
||||||
|
|
||||||
private UplinkMenu? _menu;
|
private UplinkMenu? _menu;
|
||||||
private UplinkMenuPopup? _failPopup;
|
|
||||||
|
|
||||||
public UplinkBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
public UplinkBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
||||||
{
|
{
|
||||||
@@ -28,23 +16,12 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
|
|
||||||
protected override void Open()
|
protected override void Open()
|
||||||
{
|
{
|
||||||
_menu = new UplinkMenu(_prototypeManager);
|
_menu = new UplinkMenu();
|
||||||
_menu.OpenCentered();
|
_menu.OpenCentered();
|
||||||
_menu.OnClose += Close;
|
_menu.OnClose += Close;
|
||||||
|
|
||||||
_menu.OnListingButtonPressed += (_, listing) =>
|
_menu.OnListingButtonPressed += (_, listing) =>
|
||||||
{
|
{
|
||||||
if (_menu.CurrentLoggedInAccount?.DataBalance < listing.Price)
|
|
||||||
{
|
|
||||||
_failPopup = new UplinkMenuPopup(Loc.GetString("uplink-bound-user-interface-insufficient-funds-popup"));
|
|
||||||
_userInterfaceManager.ModalRoot.AddChild(_failPopup);
|
|
||||||
_failPopup.Open(UIBox2.FromDimensions(_menu.Position.X + 150, _menu.Position.Y + 60, 156, 24));
|
|
||||||
_menu.OnClose += () =>
|
|
||||||
{
|
|
||||||
_failPopup.Dispose();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
SendMessage(new UplinkBuyListingMessage(listing.ItemId));
|
SendMessage(new UplinkBuyListingMessage(listing.ItemId));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -54,59 +31,36 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
SendMessage(new UplinkRequestUpdateInterfaceMessage());
|
SendMessage(new UplinkRequestUpdateInterfaceMessage());
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
|
||||||
|
_menu.OnWithdrawAttempt += (tc) =>
|
||||||
|
{
|
||||||
|
SendMessage(new UplinkTryWithdrawTC(tc));
|
||||||
|
};
|
||||||
|
}
|
||||||
protected override void UpdateState(BoundUserInterfaceState state)
|
protected override void UpdateState(BoundUserInterfaceState state)
|
||||||
{
|
{
|
||||||
base.UpdateState(state);
|
base.UpdateState(state);
|
||||||
|
|
||||||
if (_menu == null)
|
if (_menu == null)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case UplinkUpdateState msg:
|
case UplinkUpdateState msg:
|
||||||
{
|
_menu.UpdateAccount(msg.Account);
|
||||||
_menu.CurrentLoggedInAccount = msg.Account;
|
_menu.UpdateListing(msg.Listings);
|
||||||
var balance = msg.Account.DataBalance;
|
|
||||||
string weightedColor = balance switch
|
|
||||||
{
|
|
||||||
<= 0 => "gray",
|
|
||||||
<= 5 => "green",
|
|
||||||
<= 20 => "yellow",
|
|
||||||
<= 50 => "purple",
|
|
||||||
_ => "gray"
|
|
||||||
};
|
|
||||||
_menu.BalanceInfo.SetMarkup(Loc.GetString("uplink-bound-user-interface-tc-balance-popup",
|
|
||||||
("weightedColor", weightedColor),
|
|
||||||
("balance", balance)));
|
|
||||||
|
|
||||||
_menu.ClearListings();
|
|
||||||
foreach (var item in
|
|
||||||
msg.Listings) //Should probably chunk these out instead. to-do if this clogs the internet tubes.
|
|
||||||
{
|
|
||||||
_menu.AddListingGui(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private sealed class UplinkMenuPopup : Popup
|
protected override void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
public UplinkMenuPopup(string text)
|
base.Dispose(disposing);
|
||||||
{
|
if (!disposing)
|
||||||
var label = new RichTextLabel();
|
return;
|
||||||
label.SetMessage(text);
|
|
||||||
AddChild(new PanelContainer
|
_menu?.Close();
|
||||||
{
|
_menu?.Dispose();
|
||||||
StyleClasses = { ExamineSystem.StyleClassEntityTooltip },
|
|
||||||
Children = { label }
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,13 @@
|
|||||||
MinWidth="64"/>
|
MinWidth="64"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<PanelContainer StyleClasses="HighDivider" />
|
<PanelContainer StyleClasses="HighDivider" />
|
||||||
<RichTextLabel Name="UplinkItemDescription" />
|
<BoxContainer Orientation="Horizontal"
|
||||||
|
HorizontalExpand="True">
|
||||||
|
<TextureRect Name="UplinkItemTexture"
|
||||||
|
MinSize="48 48"
|
||||||
|
Margin="0 0 4 0"
|
||||||
|
Stretch="KeepAspectCentered"/>
|
||||||
|
<RichTextLabel Name="UplinkItemDescription" />
|
||||||
|
</BoxContainer>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
</Control>
|
</Control>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Robust.Client.AutoGenerated;
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.Graphics;
|
||||||
using Robust.Client.UserInterface;
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
@@ -9,7 +10,9 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public partial class UplinkListingControl : Control
|
public partial class UplinkListingControl : Control
|
||||||
{
|
{
|
||||||
public UplinkListingControl(string itemName, string itemDescription, int itemPrice, bool canBuy)
|
|
||||||
|
public UplinkListingControl(string itemName, string itemDescription,
|
||||||
|
int itemPrice, bool canBuy, Texture? texture = null)
|
||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
|
|
||||||
@@ -18,6 +21,8 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
|
|
||||||
UplinkItemBuyButton.Text = $"{itemPrice} TC";
|
UplinkItemBuyButton.Text = $"{itemPrice} TC";
|
||||||
UplinkItemBuyButton.Disabled = !canBuy;
|
UplinkItemBuyButton.Disabled = !canBuy;
|
||||||
|
|
||||||
|
UplinkItemTexture.Texture = texture;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,10 @@
|
|||||||
Access="Public"
|
Access="Public"
|
||||||
HorizontalExpand="True"
|
HorizontalExpand="True"
|
||||||
HorizontalAlignment="Left" />
|
HorizontalAlignment="Left" />
|
||||||
|
<Button Name="WithdrawButton"
|
||||||
|
Text="Withdraw"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
MinWidth="64"/>
|
||||||
</BoxContainer>
|
</BoxContainer>
|
||||||
<PanelContainer VerticalExpand="True">
|
<PanelContainer VerticalExpand="True">
|
||||||
<PanelContainer.PanelOverride>
|
<PanelContainer.PanelOverride>
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using Content.Client.Message;
|
||||||
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;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.ResourceManagement;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Client.UserInterface.XAML;
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Client.Utility;
|
||||||
|
using Robust.Shared.IoC;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
using Robust.Shared.Maths;
|
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
namespace Content.Client.Traitor.Uplink
|
namespace Content.Client.Traitor.Uplink
|
||||||
@@ -14,18 +18,25 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
[GenerateTypedNameReferences]
|
[GenerateTypedNameReferences]
|
||||||
public partial class UplinkMenu : SS14Window
|
public partial class UplinkMenu : SS14Window
|
||||||
{
|
{
|
||||||
private readonly IPrototypeManager _prototypeManager;
|
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||||
|
[Dependency] private readonly IResourceCache _resourceCache = default!;
|
||||||
|
|
||||||
|
private UplinkWithdrawWindow? _withdrawWindow;
|
||||||
|
|
||||||
public event Action<BaseButton.ButtonEventArgs, UplinkListingData>? OnListingButtonPressed;
|
public event Action<BaseButton.ButtonEventArgs, UplinkListingData>? OnListingButtonPressed;
|
||||||
public event Action<BaseButton.ButtonEventArgs, UplinkCategory>? OnCategoryButtonPressed;
|
public event Action<BaseButton.ButtonEventArgs, UplinkCategory>? OnCategoryButtonPressed;
|
||||||
|
public event Action<int>? OnWithdrawAttempt;
|
||||||
|
|
||||||
public UplinkMenu(IPrototypeManager prototypeManager)
|
private UplinkCategory _currentFilter;
|
||||||
|
private UplinkAccountData? _loggedInUplinkAccount;
|
||||||
|
|
||||||
|
public UplinkMenu()
|
||||||
{
|
{
|
||||||
RobustXamlLoader.Load(this);
|
RobustXamlLoader.Load(this);
|
||||||
|
IoCManager.InjectDependencies(this);
|
||||||
_prototypeManager = prototypeManager;
|
|
||||||
|
|
||||||
PopulateUplinkCategoryButtons();
|
PopulateUplinkCategoryButtons();
|
||||||
|
WithdrawButton.OnButtonDown += OnWithdrawButtonDown;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UplinkCategory CurrentFilterCategory
|
public UplinkCategory CurrentFilterCategory
|
||||||
@@ -42,16 +53,60 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UplinkAccountData? CurrentLoggedInAccount
|
public void UpdateAccount(UplinkAccountData account)
|
||||||
{
|
{
|
||||||
get => _loggedInUplinkAccount;
|
_loggedInUplinkAccount = account;
|
||||||
set => _loggedInUplinkAccount = value;
|
|
||||||
|
// update balance label
|
||||||
|
var balance = account.DataBalance;
|
||||||
|
var weightedColor = balance switch
|
||||||
|
{
|
||||||
|
<= 0 => "gray",
|
||||||
|
<= 5 => "green",
|
||||||
|
<= 20 => "yellow",
|
||||||
|
<= 50 => "purple",
|
||||||
|
_ => "gray"
|
||||||
|
};
|
||||||
|
var balanceStr = Loc.GetString("uplink-bound-user-interface-tc-balance-popup",
|
||||||
|
("weightedColor", weightedColor),
|
||||||
|
("balance", balance));
|
||||||
|
BalanceInfo.SetMarkup(balanceStr);
|
||||||
|
|
||||||
|
// you can't withdraw if you don't have TC
|
||||||
|
WithdrawButton.Disabled = balance <= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private UplinkCategory _currentFilter;
|
public void UpdateListing(UplinkListingData[] listings)
|
||||||
private UplinkAccountData? _loggedInUplinkAccount;
|
{
|
||||||
|
// should probably chunk these out instead. to-do if this clogs the internet tubes.
|
||||||
|
// maybe read clients prototypes instead?
|
||||||
|
ClearListings();
|
||||||
|
foreach (var item in listings)
|
||||||
|
{
|
||||||
|
AddListingGui(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void AddListingGui(UplinkListingData listing)
|
private void OnWithdrawButtonDown(BaseButton.ButtonEventArgs args)
|
||||||
|
{
|
||||||
|
if (_loggedInUplinkAccount == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// check if window is already open
|
||||||
|
if (_withdrawWindow != null && _withdrawWindow.IsOpen)
|
||||||
|
{
|
||||||
|
_withdrawWindow.MoveToFront();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// open a new one
|
||||||
|
_withdrawWindow = new UplinkWithdrawWindow(_loggedInUplinkAccount.DataBalance);
|
||||||
|
_withdrawWindow.OpenCentered();
|
||||||
|
|
||||||
|
_withdrawWindow.OnWithdrawAttempt += OnWithdrawAttempt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AddListingGui(UplinkListingData listing)
|
||||||
{
|
{
|
||||||
if (!_prototypeManager.TryIndex(listing.ItemId, out EntityPrototype? prototype) || listing.Category != CurrentFilterCategory)
|
if (!_prototypeManager.TryIndex(listing.ItemId, out EntityPrototype? prototype) || listing.Category != CurrentFilterCategory)
|
||||||
{
|
{
|
||||||
@@ -63,14 +118,19 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
var listingPrice = listing.Price;
|
var listingPrice = listing.Price;
|
||||||
var canBuy = _loggedInUplinkAccount?.DataBalance >= listing.Price;
|
var canBuy = _loggedInUplinkAccount?.DataBalance >= listing.Price;
|
||||||
|
|
||||||
var newListing = new UplinkListingControl(listingName, listingDesc, listingPrice, canBuy);
|
var texture = listing.Icon?.Frame0();
|
||||||
|
if (texture == null)
|
||||||
|
texture = SpriteComponent.GetPrototypeIcon(prototype, _resourceCache).Default;
|
||||||
|
|
||||||
|
|
||||||
|
var newListing = new UplinkListingControl(listingName, listingDesc, listingPrice, canBuy, texture);
|
||||||
newListing.UplinkItemBuyButton.OnButtonDown += args
|
newListing.UplinkItemBuyButton.OnButtonDown += args
|
||||||
=> OnListingButtonPressed?.Invoke(args, listing);
|
=> OnListingButtonPressed?.Invoke(args, listing);
|
||||||
|
|
||||||
UplinkListingsContainer.AddChild(newListing);
|
UplinkListingsContainer.AddChild(newListing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClearListings()
|
private void ClearListings()
|
||||||
{
|
{
|
||||||
UplinkListingsContainer.Children.Clear();
|
UplinkListingsContainer.Children.Clear();
|
||||||
}
|
}
|
||||||
@@ -93,6 +153,12 @@ namespace Content.Client.Traitor.Uplink
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
base.Close();
|
||||||
|
_withdrawWindow?.Close();
|
||||||
|
}
|
||||||
|
|
||||||
private sealed class PDAUplinkCategoryButton : Button
|
private sealed class PDAUplinkCategoryButton : Button
|
||||||
{
|
{
|
||||||
public UplinkCategory ButtonCategory;
|
public UplinkCategory ButtonCategory;
|
||||||
|
|||||||
22
Content.Client/Traitor/Uplink/UplinkWithdrawWindow.xaml
Normal file
22
Content.Client/Traitor/Uplink/UplinkWithdrawWindow.xaml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<SS14Window xmlns="https://spacestation14.io"
|
||||||
|
Title="{Loc 'uplink-user-interface-withdraw-title'}"
|
||||||
|
MinSize="256 128">
|
||||||
|
<BoxContainer Orientation="Vertical"
|
||||||
|
HorizontalExpand="True"
|
||||||
|
VerticalExpand="True">
|
||||||
|
<SliderIntInput Name="WithdrawSlider"
|
||||||
|
HorizontalExpand="True"/>
|
||||||
|
<BoxContainer Orientation="Horizontal"
|
||||||
|
VerticalExpand="True"
|
||||||
|
VerticalAlignment="Bottom">
|
||||||
|
<Button Name="ApplyButton"
|
||||||
|
Text="{Loc 'uplink-user-interface-withdraw-withdraw-button'}"
|
||||||
|
HorizontalAlignment="Left"
|
||||||
|
HorizontalExpand="True"/>
|
||||||
|
<Button Name="CancelButton"
|
||||||
|
Text="{Loc 'uplink-user-interface-withdraw-cancel-button'}"
|
||||||
|
HorizontalAlignment="Right"
|
||||||
|
HorizontalExpand="True"/>
|
||||||
|
</BoxContainer>
|
||||||
|
</BoxContainer>
|
||||||
|
</SS14Window>
|
||||||
34
Content.Client/Traitor/Uplink/UplinkWithdrawWindow.xaml.cs
Normal file
34
Content.Client/Traitor/Uplink/UplinkWithdrawWindow.xaml.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using Robust.Client.AutoGenerated;
|
||||||
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
|
using Robust.Client.UserInterface.XAML;
|
||||||
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
|
namespace Content.Client.Traitor.Uplink
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Window to select amount TC to withdraw from Uplink account
|
||||||
|
/// Used as sub-window in Uplink UI
|
||||||
|
/// </summary>
|
||||||
|
[GenerateTypedNameReferences]
|
||||||
|
public partial class UplinkWithdrawWindow : SS14Window
|
||||||
|
{
|
||||||
|
public event System.Action<int>? OnWithdrawAttempt;
|
||||||
|
|
||||||
|
public UplinkWithdrawWindow(int tcCount)
|
||||||
|
{
|
||||||
|
RobustXamlLoader.Load(this);
|
||||||
|
|
||||||
|
// setup withdraw slider
|
||||||
|
WithdrawSlider.MinValue = 1;
|
||||||
|
WithdrawSlider.MaxValue = tcCount;
|
||||||
|
|
||||||
|
// and buttons
|
||||||
|
ApplyButton.OnButtonDown += _ =>
|
||||||
|
{
|
||||||
|
OnWithdrawAttempt?.Invoke(WithdrawSlider.Value);
|
||||||
|
Close();
|
||||||
|
};
|
||||||
|
CancelButton.OnButtonDown += _ => Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,9 @@
|
|||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics.CodeAnalysis;
|
using System.Diagnostics.CodeAnalysis;
|
||||||
using Content.Server.Mind.Components;
|
using Content.Server.Mind.Components;
|
||||||
|
using Content.Server.Stack;
|
||||||
|
using Content.Shared.Stacks;
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.IoC;
|
using Robust.Shared.IoC;
|
||||||
@@ -13,8 +16,12 @@ namespace Content.Server.Traitor.Uplink.Account
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class UplinkAccountsSystem : EntitySystem
|
public class UplinkAccountsSystem : EntitySystem
|
||||||
{
|
{
|
||||||
|
public const string TelecrystalProtoId = "Telecrystal";
|
||||||
|
|
||||||
[Dependency]
|
[Dependency]
|
||||||
private readonly UplinkListingSytem _listingSystem = default!;
|
private readonly UplinkListingSytem _listingSystem = default!;
|
||||||
|
[Dependency]
|
||||||
|
private readonly SharedStackSystem _stackSystem = default!;
|
||||||
|
|
||||||
private readonly HashSet<UplinkAccount> _accounts = new();
|
private readonly HashSet<UplinkAccount> _accounts = new();
|
||||||
|
|
||||||
@@ -86,5 +93,25 @@ namespace Content.Server.Traitor.Uplink.Account
|
|||||||
purchasedItem = EntityManager.SpawnEntity(listing.ItemId, spawnCoords);
|
purchasedItem = EntityManager.SpawnEntity(listing.ItemId, spawnCoords);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool TryWithdrawTC(UplinkAccount acc, int tc, EntityCoordinates spawnCoords, [NotNullWhen(true)] out EntityUid? stackUid)
|
||||||
|
{
|
||||||
|
stackUid = null;
|
||||||
|
|
||||||
|
// try to charge TC from players account
|
||||||
|
var actTC = Math.Min(tc, acc.Balance);
|
||||||
|
if (actTC <= 0)
|
||||||
|
return false;
|
||||||
|
if (!RemoveFromBalance(acc, actTC))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// create a stack of TCs near player
|
||||||
|
var stackEntity = EntityManager.SpawnEntity(TelecrystalProtoId, spawnCoords);
|
||||||
|
stackUid = stackEntity.Uid;
|
||||||
|
|
||||||
|
// set right amount in stack
|
||||||
|
_stackSystem.SetCount(stackUid.Value, actTC);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace Content.Server.Traitor.Uplink
|
|||||||
foreach (var item in _prototypeManager.EnumeratePrototypes<UplinkStoreListingPrototype>())
|
foreach (var item in _prototypeManager.EnumeratePrototypes<UplinkStoreListingPrototype>())
|
||||||
{
|
{
|
||||||
var newListing = new UplinkListingData(item.ListingName, item.ItemId,
|
var newListing = new UplinkListingData(item.ListingName, item.ItemId,
|
||||||
item.Price, item.Category, item.Description);
|
item.Price, item.Category, item.Description, item.Icon);
|
||||||
|
|
||||||
RegisterUplinkListing(newListing);
|
RegisterUplinkListing(newListing);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ 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.Hands.Components;
|
||||||
using Content.Shared.Interaction;
|
using Content.Shared.Interaction;
|
||||||
using Content.Shared.Traitor.Uplink;
|
using Content.Shared.Traitor.Uplink;
|
||||||
using Robust.Server.GameObjects;
|
using Robust.Server.GameObjects;
|
||||||
@@ -34,8 +35,11 @@ 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, UseInHandEvent>(OnUseHand);
|
||||||
|
|
||||||
|
// UI events
|
||||||
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy);
|
SubscribeLocalEvent<UplinkComponent, UplinkBuyListingMessage>(OnBuy);
|
||||||
SubscribeLocalEvent<UplinkComponent, UplinkRequestUpdateInterfaceMessage>(OnRequestUpdateUI);
|
SubscribeLocalEvent<UplinkComponent, UplinkRequestUpdateInterfaceMessage>(OnRequestUpdateUI);
|
||||||
|
SubscribeLocalEvent<UplinkComponent, UplinkTryWithdrawTC>(OnWithdrawTC);
|
||||||
|
|
||||||
SubscribeLocalEvent<UplinkAccountBalanceChanged>(OnBalanceChangedBroadcast);
|
SubscribeLocalEvent<UplinkAccountBalanceChanged>(OnBalanceChangedBroadcast);
|
||||||
}
|
}
|
||||||
@@ -131,6 +135,31 @@ namespace Content.Server.Traitor.Uplink
|
|||||||
RaiseNetworkEvent(new UplinkBuySuccessMessage(), message.Session.ConnectedClient);
|
RaiseNetworkEvent(new UplinkBuySuccessMessage(), message.Session.ConnectedClient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnWithdrawTC(EntityUid uid, UplinkComponent uplink, UplinkTryWithdrawTC args)
|
||||||
|
{
|
||||||
|
var acc = uplink.UplinkAccount;
|
||||||
|
if (acc == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var player = args.Session.AttachedEntity;
|
||||||
|
if (player == null) return;
|
||||||
|
var cords = player.Transform.Coordinates;
|
||||||
|
|
||||||
|
// try to withdraw TCs from account
|
||||||
|
if (!_accounts.TryWithdrawTC(acc, args.TC, cords, out var tcUid))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// try to put it into players hands
|
||||||
|
if (player.TryGetComponent(out SharedHandsComponent? hands))
|
||||||
|
hands.TryPutInAnyHand(EntityManager.GetEntity(tcUid.Value));
|
||||||
|
|
||||||
|
// play buying sound
|
||||||
|
SoundSystem.Play(Filter.SinglePlayer(args.Session), uplink.BuySuccessSound.GetSound(),
|
||||||
|
uplink.Owner, AudioParams.Default.WithVolume(-2f));
|
||||||
|
|
||||||
|
UpdateUserInterface(uplink);
|
||||||
|
}
|
||||||
|
|
||||||
public void ToggleUplinkUI(UplinkComponent component, IPlayerSession session)
|
public void ToggleUplinkUI(UplinkComponent component, IPlayerSession session)
|
||||||
{
|
{
|
||||||
var ui = component.Owner.GetUIOrNull(UplinkUiKey.Key);
|
var ui = component.Owner.GetUIOrNull(UplinkUiKey.Key);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
using Robust.Shared.Serialization.Manager.Attributes;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
using Robust.Shared.ViewVariables;
|
using Robust.Shared.ViewVariables;
|
||||||
|
|
||||||
namespace Content.Shared.PDA
|
namespace Content.Shared.PDA
|
||||||
@@ -25,5 +26,8 @@ namespace Content.Shared.PDA
|
|||||||
|
|
||||||
[DataField("listingName")]
|
[DataField("listingName")]
|
||||||
public string ListingName { get; } = string.Empty;
|
public string ListingName { get; } = string.Empty;
|
||||||
|
|
||||||
|
[DataField("icon")]
|
||||||
|
public SpriteSpecifier? Icon { get; } = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using Content.Shared.PDA;
|
using Content.Shared.PDA;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
|
using Robust.Shared.Utility;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace Content.Shared.Traitor.Uplink
|
namespace Content.Shared.Traitor.Uplink
|
||||||
@@ -13,16 +14,18 @@ namespace Content.Shared.Traitor.Uplink
|
|||||||
public readonly UplinkCategory Category;
|
public readonly UplinkCategory Category;
|
||||||
public readonly string Description;
|
public readonly string Description;
|
||||||
public readonly string ListingName;
|
public readonly string ListingName;
|
||||||
|
public readonly SpriteSpecifier? Icon;
|
||||||
|
|
||||||
public UplinkListingData(string listingName, string itemId,
|
public UplinkListingData(string listingName, string itemId,
|
||||||
int price, UplinkCategory category,
|
int price, UplinkCategory category,
|
||||||
string description)
|
string description, SpriteSpecifier? icon)
|
||||||
{
|
{
|
||||||
ListingName = listingName;
|
ListingName = listingName;
|
||||||
Price = price;
|
Price = price;
|
||||||
Category = category;
|
Category = category;
|
||||||
Description = description;
|
Description = description;
|
||||||
ItemId = itemId;
|
ItemId = itemId;
|
||||||
|
Icon = icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(UplinkListingData? other)
|
public bool Equals(UplinkListingData? other)
|
||||||
|
|||||||
@@ -23,4 +23,15 @@ namespace Content.Shared.Traitor.Uplink
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public sealed class UplinkTryWithdrawTC : BoundUserInterfaceMessage
|
||||||
|
{
|
||||||
|
public int TC;
|
||||||
|
|
||||||
|
public UplinkTryWithdrawTC(int tc)
|
||||||
|
{
|
||||||
|
TC = tc;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,3 +5,9 @@ uplink-bound-user-interface-tc-balance-popup = TC Balance: [color={$weightedColo
|
|||||||
uplink-user-interface-title = Uplink
|
uplink-user-interface-title = Uplink
|
||||||
|
|
||||||
uplink-user-interface-search-label = Search
|
uplink-user-interface-search-label = Search
|
||||||
|
|
||||||
|
# Withdraw UI
|
||||||
|
|
||||||
|
uplink-user-interface-withdraw-title = Withdraw TC
|
||||||
|
uplink-user-interface-withdraw-withdraw-button = Withdraw
|
||||||
|
uplink-user-interface-withdraw-cancel-button = Cancel
|
||||||
|
|||||||
@@ -4,12 +4,16 @@
|
|||||||
id: UplinkPistolClarissa
|
id: UplinkPistolClarissa
|
||||||
category: Weapons
|
category: Weapons
|
||||||
itemId: PistolClarissa
|
itemId: PistolClarissa
|
||||||
|
listingName: Clarissa
|
||||||
|
description: A small, easily concealable, but somewhat underpowered gun. Use pistol magazines (.35 auto).
|
||||||
price: 6
|
price: 6
|
||||||
|
|
||||||
- type: uplinkListing
|
- type: uplinkListing
|
||||||
id: UplinkRevolverInspector
|
id: UplinkRevolverInspector
|
||||||
category: Weapons
|
category: Weapons
|
||||||
itemId: RevolverInspector
|
itemId: RevolverInspector
|
||||||
|
listingName: Inspector
|
||||||
|
description: A .40 magnum caliber revolver. Still quite deadly, despite its ancient design.
|
||||||
price: 8
|
price: 8
|
||||||
|
|
||||||
# Inbuilt suppressor so it's sneaky + more expensive.
|
# Inbuilt suppressor so it's sneaky + more expensive.
|
||||||
@@ -17,6 +21,8 @@
|
|||||||
id: UplinkPistolMandella
|
id: UplinkPistolMandella
|
||||||
category: Weapons
|
category: Weapons
|
||||||
itemId: PistolMandella
|
itemId: PistolMandella
|
||||||
|
listingName: Mandella
|
||||||
|
description: A rugged, robust operator handgun with inbuilt silencer. Use pistol magazines (.25 caseless).
|
||||||
price: 8
|
price: 8
|
||||||
|
|
||||||
#- type: uplinkListing
|
#- type: uplinkListing
|
||||||
@@ -99,6 +105,7 @@
|
|||||||
category: Ammo
|
category: Ammo
|
||||||
itemId: SLMagnum
|
itemId: SLMagnum
|
||||||
price: 2
|
price: 2
|
||||||
|
icon: /Textures/Objects/Weapons/Guns/Ammunition/SpeedLoaders/Magnum/magnum_sl.rsi/icon.png
|
||||||
|
|
||||||
# Bundles
|
# Bundles
|
||||||
|
|
||||||
@@ -107,24 +114,28 @@
|
|||||||
category: Bundles
|
category: Bundles
|
||||||
itemId: ClothingBackpackDuffelSyndicateFilledSMG
|
itemId: ClothingBackpackDuffelSyndicateFilledSMG
|
||||||
price: 14
|
price: 14
|
||||||
|
icon: /Textures/Objects/Weapons/Guns/SMGs/c20r.rsi/icon.png
|
||||||
|
|
||||||
- type: uplinkListing
|
- type: uplinkListing
|
||||||
id: UplinkBojevicBundle
|
id: UplinkBojevicBundle
|
||||||
category: Bundles
|
category: Bundles
|
||||||
itemId: ClothingBackpackDuffelSyndicateFilledShotgun
|
itemId: ClothingBackpackDuffelSyndicateFilledShotgun
|
||||||
price: 13
|
price: 13
|
||||||
|
icon: /Textures/Objects/Weapons/Guns/Shotguns/bojevic.rsi/icon.png
|
||||||
|
|
||||||
- type: uplinkListing
|
- type: uplinkListing
|
||||||
id: UplinkL6SawBundle
|
id: UplinkL6SawBundle
|
||||||
category: Bundles
|
category: Bundles
|
||||||
itemId: ClothingBackpackDuffelSyndicateFilledLMG
|
itemId: ClothingBackpackDuffelSyndicateFilledLMG
|
||||||
price: 18
|
price: 18
|
||||||
|
icon: /Textures/Objects/Weapons/Guns/LMGs/l6.rsi/icon.png
|
||||||
|
|
||||||
- type: uplinkListing
|
- type: uplinkListing
|
||||||
id: UplinkGrenadeLauncherBundle
|
id: UplinkGrenadeLauncherBundle
|
||||||
category: Bundles
|
category: Bundles
|
||||||
itemId: ClothingBackpackDuffelSyndicateFilledGrenadeLauncher
|
itemId: ClothingBackpackDuffelSyndicateFilledGrenadeLauncher
|
||||||
price: 25
|
price: 25
|
||||||
|
icon: /Textures/Objects/Weapons/Guns/Launchers/china_lake.rsi/icon.png
|
||||||
|
|
||||||
# Tools
|
# Tools
|
||||||
|
|
||||||
@@ -217,34 +228,6 @@
|
|||||||
itemId: lanternextrabright
|
itemId: lanternextrabright
|
||||||
price: 2
|
price: 2
|
||||||
|
|
||||||
- type: uplinkListing
|
|
||||||
id: UplinkTelecrystal
|
|
||||||
category: Misc
|
|
||||||
itemId: Telecrystal1
|
|
||||||
price: 1
|
|
||||||
listingName: telecrystal [1]
|
|
||||||
|
|
||||||
- type: uplinkListing
|
|
||||||
id: UplinkTelecrystal5
|
|
||||||
category: Misc
|
|
||||||
itemId: Telecrystal5
|
|
||||||
price: 5
|
|
||||||
listingName: telecrystal [5]
|
|
||||||
|
|
||||||
- type: uplinkListing
|
|
||||||
id: UplinkTelecrystal10
|
|
||||||
category: Misc
|
|
||||||
itemId: Telecrystal10
|
|
||||||
price: 10
|
|
||||||
listingName: telecrystal [10]
|
|
||||||
|
|
||||||
- type: uplinkListing
|
|
||||||
id: UplinkTelecrystal20
|
|
||||||
category: Misc
|
|
||||||
itemId: Telecrystal
|
|
||||||
price: 20
|
|
||||||
listingName: telecrystal [20]
|
|
||||||
|
|
||||||
# Pointless
|
# Pointless
|
||||||
|
|
||||||
- type: uplinkListing
|
- type: uplinkListing
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
sprite: Objects/Specific/Syndicate/telecrystal.rsi
|
sprite: Objects/Specific/Syndicate/telecrystal.rsi
|
||||||
- type: Stack
|
- type: Stack
|
||||||
count: 20
|
count: 20
|
||||||
max: 20
|
max: 999999 # todo: add support for unlimited stacks
|
||||||
stackType: Telecrystal
|
stackType: Telecrystal
|
||||||
- type: Telecrystal
|
- type: Telecrystal
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user