Convert almost all IActivate instances that open UIs to ActivatableUI (#7028)
* Chem master * Drone support for handhelds * Vending machines, scanners * Cloners, R&D computers * make research a little less sussy * Unfuck wires * PA control computer * Unfuck merge * Clean up git gore for good * Disposals * Microwaves * paper * Magic mirror * More vendors for drones * Solar computer whitelist * EFR review updates
This commit is contained in:
@@ -112,13 +112,23 @@ namespace Content.Server.UserInterface
|
||||
// If we've gotten this far, fire a cancellable event that indicates someone is about to activate this.
|
||||
// This is so that stuff can require further conditions (like power).
|
||||
var oae = new ActivatableUIOpenAttemptEvent(user);
|
||||
var uae = new UserOpenActivatableUIAttemptEvent(user);
|
||||
var uae = new UserOpenActivatableUIAttemptEvent(user, aui.Owner);
|
||||
RaiseLocalEvent(user, uae, false);
|
||||
RaiseLocalEvent((aui).Owner, oae, false);
|
||||
if (oae.Cancelled || uae.Cancelled) return false;
|
||||
|
||||
// Give the UI an opportunity to prepare itself if it needs to do anything
|
||||
// before opening
|
||||
var bae = new BeforeActivatableUIOpenEvent(user);
|
||||
RaiseLocalEvent((aui).Owner, bae, false);
|
||||
|
||||
SetCurrentSingleUser((aui).Owner, actor.PlayerSession, aui);
|
||||
ui.Toggle(actor.PlayerSession);
|
||||
|
||||
//Let the component know a user opened it so it can do whatever it needs to do
|
||||
var aae = new AfterActivatableUIOpenEvent(user);
|
||||
RaiseLocalEvent((aui).Owner, aae, false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -153,11 +163,37 @@ namespace Content.Server.UserInterface
|
||||
public sealed class UserOpenActivatableUIAttemptEvent : CancellableEntityEventArgs //have to one-up the already stroke-inducing name
|
||||
{
|
||||
public EntityUid User { get; }
|
||||
public UserOpenActivatableUIAttemptEvent(EntityUid who)
|
||||
public EntityUid Target { get; }
|
||||
public UserOpenActivatableUIAttemptEvent(EntityUid who, EntityUid target)
|
||||
{
|
||||
User = who;
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class AfterActivatableUIOpenEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid User { get; }
|
||||
public AfterActivatableUIOpenEvent(EntityUid who)
|
||||
{
|
||||
User = who;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This is after it's decided the user can open the UI,
|
||||
/// but before the UI actually opens.
|
||||
/// Use this if you need to prepare the UI itself
|
||||
/// </summary>
|
||||
public sealed class BeforeActivatableUIOpenEvent : EntityEventArgs
|
||||
{
|
||||
public EntityUid User { get; }
|
||||
public BeforeActivatableUIOpenEvent(EntityUid who)
|
||||
{
|
||||
User = who;
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class ActivatableUIPlayerChangedEvent : EntityEventArgs
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user