mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
101 lines
3 KiB
C#
101 lines
3 KiB
C#
using Content.Shared.GameTicking;
|
|
using Content.Shared.Store;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.Graphics;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.Store.Ui;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class StoreListingControl : Control
|
|
{
|
|
[Dependency] private IPrototypeManager _prototype = default!;
|
|
[Dependency] private IEntityManager _entity = default!;
|
|
[Dependency] private IGameTiming _timing = default!;
|
|
private readonly GameTicker _ticker;
|
|
|
|
private readonly ListingDataWithCostModifiers _data;
|
|
|
|
private readonly bool _hasBalance;
|
|
private readonly string _price;
|
|
private readonly string _discount;
|
|
public StoreListingControl(ListingDataWithCostModifiers data, string price, string discount, bool hasBalance, Texture? texture = null)
|
|
{
|
|
IoCManager.InjectDependencies(this);
|
|
RobustXamlLoader.Load(this);
|
|
|
|
_ticker = _entity.System<GameTicker>();
|
|
|
|
_data = data;
|
|
_hasBalance = hasBalance;
|
|
_price = price;
|
|
_discount = discount;
|
|
|
|
StoreItemName.Text = ListingLocalisationHelpers.GetLocalisedNameOrEntityName(_data, _prototype);
|
|
StoreItemDescription.SetMessage(ListingLocalisationHelpers.GetLocalisedDescriptionOrEntityDescription(_data, _prototype));
|
|
|
|
UpdateBuyButtonText();
|
|
StoreItemBuyButton.Disabled = !CanBuy();
|
|
|
|
StoreItemTexture.Texture = texture;
|
|
}
|
|
|
|
private bool CanBuy()
|
|
{
|
|
if (!_hasBalance)
|
|
return false;
|
|
|
|
var stationTime = _timing.CurTime.Subtract(_ticker.RoundStartTimeSpan);
|
|
if (_data.RestockTime > stationTime)
|
|
return false;
|
|
|
|
if (_data.Locked)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
private void UpdateBuyButtonText()
|
|
{
|
|
var stationTime = _timing.CurTime.Subtract(_ticker.RoundStartTimeSpan);
|
|
if (_data.RestockTime > stationTime)
|
|
{
|
|
var timeLeftToBuy = stationTime - _data.RestockTime;
|
|
StoreItemBuyButton.Text = timeLeftToBuy.Duration().ToString(@"mm\:ss");
|
|
}
|
|
else if (_data.Locked)
|
|
{
|
|
StoreItemBuyButton.Text = Loc.GetString("store-listing-locked");
|
|
}
|
|
else
|
|
{
|
|
DiscountSubText.Text = _discount;
|
|
StoreItemBuyButton.Text = _price;
|
|
}
|
|
}
|
|
|
|
private void UpdateName()
|
|
{
|
|
var name = ListingLocalisationHelpers.GetLocalisedNameOrEntityName(_data, _prototype);
|
|
|
|
var stationTime = _timing.CurTime.Subtract(_ticker.RoundStartTimeSpan);
|
|
if (_data.RestockTime > stationTime)
|
|
{
|
|
name += Loc.GetString("store-ui-button-out-of-stock");
|
|
}
|
|
|
|
StoreItemName.Text = name;
|
|
}
|
|
|
|
protected override void FrameUpdate(FrameEventArgs args)
|
|
{
|
|
base.FrameUpdate(args);
|
|
|
|
UpdateBuyButtonText();
|
|
UpdateName();
|
|
StoreItemBuyButton.Disabled = !CanBuy();
|
|
}
|
|
}
|