Adds even more smites and a bunch of tools. (#9825)
* Adds three new smites, headstand, locker stuff, and reptilian species swap. * Localize all the smites. * save work * More smites... * Final tweaks. * oops * !PLEH * Adds disarm prone and improved hand removal options. * fix chances. * take out the trash. * Add some admin TRICKS instead of more smites. * oop * Implements the admin test arena and associated trick. * Tricks for granting/revoking access. * e * mfw * Implement quick dialogs, for when you don't want to spend 20 minutes writing a simple dialog prompt. * Forgot the rejuv icon. * E * docs * augh * Add rename/redescribe buttons. * Adds objects menu, implements a couple tricks for stations. * 1984 * Adds a trick for effectively infinite power. * fixes some icon uggo. * a * HALT! * Pause/unpause buttons. * Forgor the textures. * they broke every bone in their body. * i added more * more battery actions, touch up battery icon. * Address reviews.
This commit is contained in:
176
Content.Server/Administration/QuickDialogSystem.OpenDialog.cs
Normal file
176
Content.Server/Administration/QuickDialogSystem.OpenDialog.cs
Normal file
@@ -0,0 +1,176 @@
|
||||
using Content.Shared.Administration;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.Player;
|
||||
|
||||
namespace Content.Server.Administration;
|
||||
|
||||
public sealed partial class QuickDialogSystem
|
||||
{
|
||||
/// <summary>
|
||||
/// Opens a dialog for the given client, allowing them to enter in the desired data.
|
||||
/// </summary>
|
||||
/// <param name="session">Client to show a dialog for.</param>
|
||||
/// <param name="title">Title of the dialog.</param>
|
||||
/// <param name="prompt">The prompt.</param>
|
||||
/// <param name="okAction">The action to execute upon Ok being pressed.</param>
|
||||
/// <param name="cancelAction">The action to execute upon the dialog being cancelled.</param>
|
||||
/// <typeparam name="T1">Type of the input.</typeparam>
|
||||
[PublicAPI]
|
||||
public void OpenDialog<T1>(IPlayerSession session, string title, string prompt, Action<T1> okAction,
|
||||
Action? cancelAction = null)
|
||||
{
|
||||
OpenDialogInternal(
|
||||
session,
|
||||
title,
|
||||
new List<QuickDialogEntry>
|
||||
{
|
||||
new("1", TypeToEntryType(typeof(T1)), prompt)
|
||||
},
|
||||
QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton,
|
||||
(ev =>
|
||||
{
|
||||
if (TryParseQuickDialog<T1>(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1))
|
||||
okAction.Invoke(v1);
|
||||
else
|
||||
{
|
||||
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
|
||||
cancelAction?.Invoke();
|
||||
}
|
||||
}),
|
||||
cancelAction ?? (() => { })
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a dialog for the given client, allowing them to enter in the desired data.
|
||||
/// </summary>
|
||||
/// <param name="session">Client to show a dialog for.</param>
|
||||
/// <param name="title">Title of the dialog.</param>
|
||||
/// <param name="prompt1">The first prompt.</param>
|
||||
/// <param name="prompt2">The second prompt.</param>
|
||||
/// <param name="okAction">The action to execute upon Ok being pressed.</param>
|
||||
/// <param name="cancelAction">The action to execute upon the dialog being cancelled.</param>
|
||||
/// <typeparam name="T1">Type of the first input.</typeparam>
|
||||
/// <typeparam name="T2">Type of the second input.</typeparam>
|
||||
[PublicAPI]
|
||||
public void OpenDialog<T1, T2>(IPlayerSession session, string title, string prompt1, string prompt2,
|
||||
Action<T1, T2> okAction, Action? cancelAction = null)
|
||||
{
|
||||
OpenDialogInternal(
|
||||
session,
|
||||
title,
|
||||
new List<QuickDialogEntry>
|
||||
{
|
||||
new("1", TypeToEntryType(typeof(T1)), prompt1),
|
||||
new("2", TypeToEntryType(typeof(T2)), prompt2)
|
||||
},
|
||||
QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton,
|
||||
(ev =>
|
||||
{
|
||||
|
||||
if (TryParseQuickDialog<T1>(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) &&
|
||||
TryParseQuickDialog<T2>(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2)
|
||||
)
|
||||
okAction.Invoke(v1, v2);
|
||||
else
|
||||
{
|
||||
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
|
||||
cancelAction?.Invoke();
|
||||
}
|
||||
}),
|
||||
cancelAction ?? (() => { })
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a dialog for the given client, allowing them to enter in the desired data.
|
||||
/// </summary>
|
||||
/// <param name="session">Client to show a dialog for.</param>
|
||||
/// <param name="title">Title of the dialog.</param>
|
||||
/// <param name="prompt1">The first prompt.</param>
|
||||
/// <param name="prompt2">The second prompt.</param>
|
||||
/// <param name="prompt3">The third prompt.</param>
|
||||
/// <param name="okAction">The action to execute upon Ok being pressed.</param>
|
||||
/// <param name="cancelAction">The action to execute upon the dialog being cancelled.</param>
|
||||
/// <typeparam name="T1">Type of the first input.</typeparam>
|
||||
/// <typeparam name="T2">Type of the second input.</typeparam>
|
||||
/// <typeparam name="T3">Type of the third input.</typeparam>
|
||||
[PublicAPI]
|
||||
public void OpenDialog<T1, T2, T3>(IPlayerSession session, string title, string prompt1, string prompt2,
|
||||
string prompt3, Action<T1, T2, T3> okAction, Action? cancelAction = null)
|
||||
{
|
||||
OpenDialogInternal(
|
||||
session,
|
||||
title,
|
||||
new List<QuickDialogEntry>
|
||||
{
|
||||
new("1", TypeToEntryType(typeof(T1)), prompt1),
|
||||
new("2", TypeToEntryType(typeof(T2)), prompt2),
|
||||
new("3", TypeToEntryType(typeof(T3)), prompt3)
|
||||
},
|
||||
QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton,
|
||||
(ev =>
|
||||
{
|
||||
if (TryParseQuickDialog<T1>(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) &&
|
||||
TryParseQuickDialog<T2>(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) &&
|
||||
TryParseQuickDialog<T3>(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3)
|
||||
)
|
||||
okAction.Invoke(v1, v2, v3);
|
||||
else
|
||||
{
|
||||
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
|
||||
cancelAction?.Invoke();
|
||||
}
|
||||
}),
|
||||
cancelAction ?? (() => { })
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens a dialog for the given client, allowing them to enter in the desired data.
|
||||
/// </summary>
|
||||
/// <param name="session">Client to show a dialog for.</param>
|
||||
/// <param name="title">Title of the dialog.</param>
|
||||
/// <param name="prompt1">The first prompt.</param>
|
||||
/// <param name="prompt2">The second prompt.</param>
|
||||
/// <param name="prompt3">The third prompt.</param>
|
||||
/// <param name="prompt4">The fourth prompt.</param>
|
||||
/// <param name="okAction">The action to execute upon Ok being pressed.</param>
|
||||
/// <param name="cancelAction">The action to execute upon the dialog being cancelled.</param>
|
||||
/// <typeparam name="T1">Type of the first input.</typeparam>
|
||||
/// <typeparam name="T2">Type of the second input.</typeparam>
|
||||
/// <typeparam name="T3">Type of the third input.</typeparam>
|
||||
/// <typeparam name="T4">Type of the fourth input.</typeparam>
|
||||
[PublicAPI]
|
||||
public void OpenDialog<T1, T2, T3, T4>(IPlayerSession session, string title, string prompt1, string prompt2,
|
||||
string prompt3, string prompt4, Action<T1, T2, T3, T4> okAction, Action? cancelAction = null)
|
||||
{
|
||||
OpenDialogInternal(
|
||||
session,
|
||||
title,
|
||||
new List<QuickDialogEntry>
|
||||
{
|
||||
new("1", TypeToEntryType(typeof(T1)), prompt1),
|
||||
new("2", TypeToEntryType(typeof(T2)), prompt2),
|
||||
new("3", TypeToEntryType(typeof(T3)), prompt3),
|
||||
new("4", TypeToEntryType(typeof(T4)), prompt4),
|
||||
},
|
||||
QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton,
|
||||
(ev =>
|
||||
{
|
||||
if (TryParseQuickDialog<T1>(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) &&
|
||||
TryParseQuickDialog<T2>(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) &&
|
||||
TryParseQuickDialog<T3>(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) &&
|
||||
TryParseQuickDialog<T4>(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4)
|
||||
)
|
||||
okAction.Invoke(v1, v2, v3, v4);
|
||||
else
|
||||
{
|
||||
session.ConnectedClient.Disconnect("Replied with invalid quick dialog data.");
|
||||
cancelAction?.Invoke();
|
||||
}
|
||||
}),
|
||||
cancelAction ?? (() => { })
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user