uplink locking/unlocking, minor pda refactor (#15842)

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-05-01 06:30:08 +00:00
committed by GitHub
parent 904d61baee
commit 44f9c098ec
13 changed files with 134 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
using Content.Server.Actions;
using Content.Server.Administration.Logs;
using Content.Server.PDA.Ringer;
using Content.Server.Stack;
using Content.Server.Store.Components;
using Content.Server.UserInterface;
@@ -49,6 +50,17 @@ public sealed partial class StoreSystem
UpdateUserInterface(user, storeEnt, component);
}
/// <summary>
/// Closes the store UI for everyone, if it's open
/// </summary>
public void CloseUi(EntityUid uid, StoreComponent? component = null)
{
if (!Resolve(uid, ref component))
return;
_ui.TryCloseAll(uid, StoreUiKey.Key);
}
/// <summary>
/// Updates the user interface for a store and refreshes the listings
/// </summary>
@@ -83,7 +95,9 @@ public sealed partial class StoreSystem
// TODO: if multiple users are supposed to be able to interact with a single BUI & see different
// stores/listings, this needs to use session specific BUI states.
var state = new StoreUpdateState(component.LastAvailableListings, allCurrency);
// only tell operatives to lock their uplink if it can be locked
var showFooter = HasComp<RingerUplinkComponent>(store);
var state = new StoreUpdateState(component.LastAvailableListings, allCurrency, showFooter);
_ui.SetUiState(ui, state);
}

View File

@@ -1,4 +1,5 @@
using Content.Server.Mind.Components;
using Content.Server.PDA.Ringer;
using Content.Server.Store.Components;
using Content.Server.UserInterface;
using Content.Shared.FixedPoint;
@@ -72,9 +73,9 @@ public sealed partial class StoreSystem : EntitySystem
if (args.Target == null || !TryComp<StoreComponent>(args.Target, out var store))
return;
// require the store to be open before inserting currency
// if the store can be locked, it must be unlocked first before inserting currency
var user = args.User;
if (!TryComp<ActorComponent>(user, out var actor) || !_ui.SessionHasOpenUi(uid, StoreUiKey.Key, actor.PlayerSession))
if (TryComp<RingerUplinkComponent>(args.Target, out var uplink) && !uplink.Unlocked)
return;
args.Handled = TryAddCurrency(GetCurrencyValue(uid, component), args.Target.Value, store);
@@ -183,6 +184,8 @@ public sealed partial class StoreSystem : EntitySystem
var ui = _ui.GetUiOrNull(uid, StoreUiKey.Key);
if (ui != null)
{
_ui.SetUiState(ui, new StoreInitializeState(preset.StoreName));
}
}
}