Makes accept cloning message use Eui (#2910)
This commit is contained in:
committed by
GitHub
parent
c04a0270e1
commit
9c2aaef73a
@@ -1,45 +0,0 @@
|
|||||||
using Content.Shared.GameObjects.Components;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Client.GameObjects.Components.UserInterface;
|
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components
|
|
||||||
{
|
|
||||||
[UsedImplicitly]
|
|
||||||
public class AcceptCloningBoundUserInterface : BoundUserInterface
|
|
||||||
{
|
|
||||||
|
|
||||||
public AcceptCloningBoundUserInterface(ClientUserInterfaceComponent owner, object uiKey) : base(owner, uiKey)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private AcceptCloningWindow _window;
|
|
||||||
|
|
||||||
protected override void Open()
|
|
||||||
{
|
|
||||||
base.Open();
|
|
||||||
|
|
||||||
_window = new AcceptCloningWindow();
|
|
||||||
_window.OnClose += Close;
|
|
||||||
_window.DenyButton.OnPressed += _ => _window.Close();
|
|
||||||
_window.ConfirmButton.OnPressed += _ =>
|
|
||||||
{
|
|
||||||
SendMessage(
|
|
||||||
new SharedAcceptCloningComponent.UiButtonPressedMessage(
|
|
||||||
SharedAcceptCloningComponent.UiButton.Accept));
|
|
||||||
_window.Close();
|
|
||||||
};
|
|
||||||
_window.OpenCentered();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
base.Dispose(disposing);
|
|
||||||
|
|
||||||
if (disposing)
|
|
||||||
{
|
|
||||||
_window?.Dispose();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
using Content.Client.Eui;
|
||||||
|
using Content.Shared.GameObjects.Components.Medical;
|
||||||
|
using Content.Shared.GameObjects.Components.Observer;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
|
||||||
|
namespace Content.Client.GameObjects.Components.Observer
|
||||||
|
{
|
||||||
|
[UsedImplicitly]
|
||||||
|
public class AcceptCloningEui : BaseEui
|
||||||
|
{
|
||||||
|
private readonly AcceptCloningWindow _window;
|
||||||
|
|
||||||
|
public AcceptCloningEui()
|
||||||
|
{
|
||||||
|
_window = new AcceptCloningWindow();
|
||||||
|
|
||||||
|
_window.DenyButton.OnPressed += _ =>
|
||||||
|
{
|
||||||
|
SendMessage(new AcceptCloningChoiceMessage(AcceptCloningUiButton.Deny));
|
||||||
|
_window.Close();
|
||||||
|
};
|
||||||
|
|
||||||
|
_window.AcceptButton.OnPressed += _ =>
|
||||||
|
{
|
||||||
|
SendMessage(new AcceptCloningChoiceMessage(AcceptCloningUiButton.Accept));
|
||||||
|
_window.Close();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Opened()
|
||||||
|
{
|
||||||
|
_window.OpenCentered();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Closed()
|
||||||
|
{
|
||||||
|
_window.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,15 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
|
using Robust.Client.UserInterface;
|
||||||
using Robust.Client.UserInterface.Controls;
|
using Robust.Client.UserInterface.Controls;
|
||||||
using Robust.Client.UserInterface.CustomControls;
|
using Robust.Client.UserInterface.CustomControls;
|
||||||
using Robust.Shared.Localization;
|
using Robust.Shared.Localization;
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components
|
namespace Content.Client.GameObjects.Components.Observer
|
||||||
{
|
{
|
||||||
public sealed class AcceptCloningWindow : SS14Window
|
public sealed class AcceptCloningWindow : SS14Window
|
||||||
{
|
{
|
||||||
public readonly Button DenyButton;
|
public readonly Button DenyButton;
|
||||||
public readonly Button ConfirmButton;
|
public readonly Button AcceptButton;
|
||||||
|
|
||||||
public AcceptCloningWindow()
|
public AcceptCloningWindow()
|
||||||
{
|
{
|
||||||
@@ -23,18 +24,25 @@ namespace Content.Client.GameObjects.Components
|
|||||||
{
|
{
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
(new Label
|
(new Label()
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("You are being cloned! Transfer your soul to the clone body?")
|
Text = Loc.GetString("You are being cloned!\nTransfer your soul to the clone body?")
|
||||||
}),
|
}),
|
||||||
new HBoxContainer
|
new HBoxContainer
|
||||||
{
|
{
|
||||||
|
Align = BoxContainer.AlignMode.Center,
|
||||||
Children =
|
Children =
|
||||||
{
|
{
|
||||||
(ConfirmButton = new Button
|
(AcceptButton = new Button
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("Yes"),
|
Text = Loc.GetString("Yes"),
|
||||||
}),
|
}),
|
||||||
|
|
||||||
|
(new Control()
|
||||||
|
{
|
||||||
|
CustomMinimumSize = (20, 0)
|
||||||
|
}),
|
||||||
|
|
||||||
(DenyButton = new Button
|
(DenyButton = new Button
|
||||||
{
|
{
|
||||||
Text = Loc.GetString("No"),
|
Text = Loc.GetString("No"),
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#nullable enable
|
#nullable enable
|
||||||
using System;
|
using System;
|
||||||
|
using Content.Server.Eui;
|
||||||
using Content.Server.GameObjects.Components.Mobs;
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
using Content.Server.GameObjects.Components.Observer;
|
using Content.Server.GameObjects.Components.Observer;
|
||||||
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
|
||||||
@@ -35,6 +36,7 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
|
[Dependency] private readonly IServerPreferencesManager _prefsManager = null!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = null!;
|
[Dependency] private readonly IPlayerManager _playerManager = null!;
|
||||||
|
[Dependency] private readonly EuiManager _euiManager = null!;
|
||||||
|
|
||||||
[ViewVariables]
|
[ViewVariables]
|
||||||
private bool Powered => !Owner.TryGetComponent(out PowerReceiverComponent? receiver) || receiver.Powered;
|
private bool Powered => !Owner.TryGetComponent(out PowerReceiverComponent? receiver) || receiver.Powered;
|
||||||
@@ -179,9 +181,11 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
_bodyContainer.Insert(mob);
|
_bodyContainer.Insert(mob);
|
||||||
_capturedMind = mind;
|
_capturedMind = mind;
|
||||||
|
|
||||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local,
|
|
||||||
new CloningStartedMessage(_capturedMind));
|
|
||||||
_status = CloningPodStatus.NoMind;
|
_status = CloningPodStatus.NoMind;
|
||||||
|
|
||||||
|
var acceptMessage = new AcceptCloningEui(mob);
|
||||||
|
_euiManager.OpenEui(acceptMessage, client);
|
||||||
|
|
||||||
UpdateAppearance();
|
UpdateAppearance();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -201,17 +205,6 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CloningStartedMessage : EntitySystemMessage
|
|
||||||
{
|
|
||||||
public CloningStartedMessage(Mind capturedMind)
|
|
||||||
{
|
|
||||||
CapturedMind = capturedMind;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Mind CapturedMind { get; }
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private HumanoidCharacterProfile GetPlayerProfileAsync(NetUserId userId)
|
private HumanoidCharacterProfile GetPlayerProfileAsync(NetUserId userId)
|
||||||
{
|
{
|
||||||
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(userId).SelectedCharacter;
|
return (HumanoidCharacterProfile) _prefsManager.GetPreferences(userId).SelectedCharacter;
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
public class MedicalScannerComponent : SharedMedicalScannerComponent, IActivate, IDragDropOn, IDestroyAct
|
public class MedicalScannerComponent : SharedMedicalScannerComponent, IActivate, IDragDropOn, IDestroyAct
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
[Dependency] private readonly IGameTiming _gameTiming = default!;
|
||||||
[Dependency] private readonly IPlayerManager _playerManager = null!;
|
|
||||||
|
|
||||||
private static readonly TimeSpan InternalOpenAttemptDelay = TimeSpan.FromSeconds(0.5);
|
private static readonly TimeSpan InternalOpenAttemptDelay = TimeSpan.FromSeconds(0.5);
|
||||||
private TimeSpan _lastInternalOpenAttempt;
|
private TimeSpan _lastInternalOpenAttempt;
|
||||||
@@ -280,16 +279,11 @@ namespace Content.Server.GameObjects.Components.Medical
|
|||||||
{
|
{
|
||||||
//TODO: Show a 'ERROR: Body is completely devoid of soul' if no Mind owns the entity.
|
//TODO: Show a 'ERROR: Body is completely devoid of soul' if no Mind owns the entity.
|
||||||
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
var cloningSystem = EntitySystem.Get<CloningSystem>();
|
||||||
cloningSystem.AddToDnaScans(_playerManager
|
|
||||||
.GetPlayersBy(playerSession =>
|
|
||||||
{
|
|
||||||
var mindOwnedMob = playerSession.ContentData()?.Mind?.OwnedEntity;
|
|
||||||
|
|
||||||
return mindOwnedMob != null && mindOwnedMob ==
|
if (!_bodyContainer.ContainedEntity.TryGetComponent(out MindComponent? mind) || !mind.HasMind)
|
||||||
_bodyContainer.ContainedEntity;
|
break;
|
||||||
}).Single()
|
|
||||||
.ContentData()
|
cloningSystem.AddToDnaScans(mind.Mind);
|
||||||
?.Mind);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -59,48 +59,6 @@ namespace Content.Server.GameObjects.Components.Mobs
|
|||||||
[ViewVariables(VVAccess.ReadWrite)]
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
public bool GhostOnShutdown { get; set; }
|
public bool GhostOnShutdown { get; set; }
|
||||||
|
|
||||||
[ViewVariables]
|
|
||||||
private BoundUserInterface? UserInterface =>
|
|
||||||
Owner.GetUIOrNull(SharedAcceptCloningComponent.AcceptCloningUiKey.Key);
|
|
||||||
|
|
||||||
|
|
||||||
public override void Initialize()
|
|
||||||
{
|
|
||||||
base.Initialize();
|
|
||||||
Owner.EntityManager.EventBus.SubscribeEvent<CloningPodComponent.CloningStartedMessage>(
|
|
||||||
EventSource.Local, this,
|
|
||||||
HandleCloningStartedMessage);
|
|
||||||
|
|
||||||
if (UserInterface != null)
|
|
||||||
{
|
|
||||||
UserInterface.OnReceiveMessage += OnUiAcceptCloningMessage;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void HandleCloningStartedMessage(CloningPodComponent.CloningStartedMessage ev)
|
|
||||||
{
|
|
||||||
if (ev.CapturedMind == Mind)
|
|
||||||
{
|
|
||||||
UserInterface?.Open(Mind.Session);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnUiAcceptCloningMessage(ServerBoundUserInterfaceMessage obj)
|
|
||||||
{
|
|
||||||
if (obj.Message is not SharedAcceptCloningComponent.UiButtonPressedMessage) return;
|
|
||||||
if (Mind != null)
|
|
||||||
{
|
|
||||||
Owner.EntityManager.EventBus.RaiseEvent(EventSource.Local, new GhostComponent.GhostReturnMessage(Mind));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OnRemove()
|
|
||||||
{
|
|
||||||
base.OnRemove();
|
|
||||||
Owner.EntityManager.EventBus.UnsubscribeEvent<CloningPodComponent.CloningStartedMessage>(EventSource.Local, this);
|
|
||||||
if (UserInterface != null) UserInterface.OnReceiveMessage -= OnUiAcceptCloningMessage;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Don't call this unless you know what the hell you're doing.
|
/// Don't call this unless you know what the hell you're doing.
|
||||||
/// Use <see cref="Mind.TransferTo(IEntity)"/> instead.
|
/// Use <see cref="Mind.TransferTo(IEntity)"/> instead.
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
#nullable enable
|
||||||
|
using Content.Server.Eui;
|
||||||
|
using Content.Server.GameObjects.Components.Mobs;
|
||||||
|
using Content.Server.Players;
|
||||||
|
using Content.Shared.Eui;
|
||||||
|
using Content.Shared.GameObjects.Components.Observer;
|
||||||
|
using Robust.Server.Interfaces.Player;
|
||||||
|
using Robust.Shared.Interfaces.GameObjects;
|
||||||
|
using Robust.Shared.Log;
|
||||||
|
|
||||||
|
namespace Content.Server.GameObjects.Components.Observer
|
||||||
|
{
|
||||||
|
public class AcceptCloningEui : BaseEui
|
||||||
|
{
|
||||||
|
private readonly IEntity _newMob;
|
||||||
|
|
||||||
|
public AcceptCloningEui(IEntity newMob)
|
||||||
|
{
|
||||||
|
_newMob = newMob;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void HandleMessage(EuiMessageBase msg)
|
||||||
|
{
|
||||||
|
base.HandleMessage(msg);
|
||||||
|
|
||||||
|
if (msg is not AcceptCloningChoiceMessage choice
|
||||||
|
|| choice.Button == AcceptCloningUiButton.Deny
|
||||||
|
|| _newMob.Deleted)
|
||||||
|
{
|
||||||
|
Close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player.ContentData()?.Mind?.TransferTo(_newMob);
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,6 +2,8 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Content.Shared.Chemistry;
|
using Content.Shared.Chemistry;
|
||||||
|
using Content.Shared.GameObjects.Components.Medical;
|
||||||
|
using Content.Shared.GameObjects.Components.Observer;
|
||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
using Robust.Shared.GameObjects.Components.UserInterface;
|
||||||
using Robust.Shared.Serialization;
|
using Robust.Shared.Serialization;
|
||||||
@@ -102,7 +104,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry.ChemMaster
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Used in <see cref="UiButtonPressedMessage"/> to specify which button was pressed.
|
/// Used in <see cref="AcceptCloningChoiceMessage"/> to specify which button was pressed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum UiAction
|
public enum UiAction
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
using System;
|
||||||
|
using Content.Shared.Eui;
|
||||||
|
using Robust.Shared.Serialization;
|
||||||
|
|
||||||
|
namespace Content.Shared.GameObjects.Components.Observer
|
||||||
|
{
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public enum AcceptCloningUiButton
|
||||||
|
{
|
||||||
|
Deny,
|
||||||
|
Accept,
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable, NetSerializable]
|
||||||
|
public class AcceptCloningChoiceMessage : EuiMessageBase
|
||||||
|
{
|
||||||
|
public readonly AcceptCloningUiButton Button;
|
||||||
|
|
||||||
|
public AcceptCloningChoiceMessage(AcceptCloningUiButton button)
|
||||||
|
{
|
||||||
|
Button = button;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
using System;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects.Components.UserInterface;
|
|
||||||
using Robust.Shared.Serialization;
|
|
||||||
|
|
||||||
namespace Content.Shared.GameObjects.Components
|
|
||||||
{
|
|
||||||
public class SharedAcceptCloningComponent : Component
|
|
||||||
{
|
|
||||||
public override string Name => "AcceptCloning";
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public enum AcceptCloningUiKey
|
|
||||||
{
|
|
||||||
Key
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public enum UiButton
|
|
||||||
{
|
|
||||||
Accept
|
|
||||||
}
|
|
||||||
|
|
||||||
[Serializable, NetSerializable]
|
|
||||||
public class UiButtonPressedMessage : BoundUserInterfaceMessage
|
|
||||||
{
|
|
||||||
public readonly UiButton Button;
|
|
||||||
|
|
||||||
public UiButtonPressedMessage(UiButton button)
|
|
||||||
{
|
|
||||||
Button = button;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -195,8 +195,6 @@
|
|||||||
interfaces:
|
interfaces:
|
||||||
- key: enum.StrippingUiKey.Key
|
- key: enum.StrippingUiKey.Key
|
||||||
type: StrippableBoundUserInterface
|
type: StrippableBoundUserInterface
|
||||||
- key: enum.AcceptCloningUiKey.Key
|
|
||||||
type: AcceptCloningBoundUserInterface
|
|
||||||
- type: Puller
|
- type: Puller
|
||||||
- type: Butcherable
|
- type: Butcherable
|
||||||
meat: FoodMeat
|
meat: FoodMeat
|
||||||
|
|||||||
Reference in New Issue
Block a user