using Content.Shared.Administration; using JetBrains.Annotations; using Robust.Shared.Player; namespace Content.Server.Administration; //res().System().TryGetSession(new EntityUid(X), out var seks);res().System().OpenDialog(seks, "Заголовок", "Серийный код твоей матери", "Селёдкой пахнет?", "Сосал?", "Сколько ванотян жрал хуёв:", "тыгыдык тыгыдык тыгыдык тыгыдык" ," ", "Вскрываем байты", (_,_,_,_,_,_,_)=>{}); // //List<(Type, string, object)> entries = new();entries.Add((typeof(string), "shitass", "idiot"));entries.Add((typeof(int), "cunt", 2254)) //res().System().TryGetSession(new EntityUid(X), out var seks);res().System().OpenDialog(seks, "Заголовок", entries, (_)=>{}); public sealed partial class QuickDialogSystem { /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt) }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if (TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1)) okAction.Invoke(v1); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The first prompt. /// The second prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the first input. /// Type of the second input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2) }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if (TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) ) okAction.Invoke(v1, v2); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The first prompt. /// The second prompt. /// The third prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the first input. /// Type of the second input. /// Type of the third input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { 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(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) ) okAction.Invoke(v1, v2, v3); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The first prompt. /// The second prompt. /// The third prompt. /// The fourth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the first input. /// Type of the second input. /// Type of the third input. /// Type of the fourth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { 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(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) ) okAction.Invoke(v1, v2, v3, v4); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The first prompt. /// The second prompt. /// The third prompt. /// The fourth prompt. /// The fifth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the first input. /// Type of the second input. /// Type of the third input. /// Type of the fourth input. /// Type of the fifth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, string prompt5, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2), new("3", TypeToEntryType(typeof(T3)), prompt3), new("4", TypeToEntryType(typeof(T4)), prompt4), new("5", TypeToEntryType(typeof(T5)), prompt5), }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if ( TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) && TryParseQuickDialog(TypeToEntryType(typeof(T5)), ev.Responses["5"], out var v5) ) okAction.Invoke(v1, v2, v3, v4, v5); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, string prompt5, string prompt6, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2), new("3", TypeToEntryType(typeof(T3)), prompt3), new("4", TypeToEntryType(typeof(T4)), prompt4), new("5", TypeToEntryType(typeof(T5)), prompt5), new("6", TypeToEntryType(typeof(T6)), prompt6), }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if ( TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) && TryParseQuickDialog(TypeToEntryType(typeof(T5)), ev.Responses["5"], out var v5) && TryParseQuickDialog(TypeToEntryType(typeof(T6)), ev.Responses["6"], out var v6) ) okAction.Invoke(v1, v2, v3, v4, v5, v6); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, string prompt5, string prompt6, string prompt7, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2), new("3", TypeToEntryType(typeof(T3)), prompt3), new("4", TypeToEntryType(typeof(T4)), prompt4), new("5", TypeToEntryType(typeof(T5)), prompt5), new("6", TypeToEntryType(typeof(T6)), prompt6), new("7", TypeToEntryType(typeof(T7)), prompt7), }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if ( TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) && TryParseQuickDialog(TypeToEntryType(typeof(T5)), ev.Responses["5"], out var v5) && TryParseQuickDialog(TypeToEntryType(typeof(T6)), ev.Responses["6"], out var v6) && TryParseQuickDialog(TypeToEntryType(typeof(T7)), ev.Responses["7"], out var v7) ) okAction.Invoke(v1, v2, v3, v4, v5, v6, v7); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, string prompt5, string prompt6, string prompt7, string prompt8, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2), new("3", TypeToEntryType(typeof(T3)), prompt3), new("4", TypeToEntryType(typeof(T4)), prompt4), new("5", TypeToEntryType(typeof(T5)), prompt5), new("6", TypeToEntryType(typeof(T6)), prompt6), new("7", TypeToEntryType(typeof(T7)), prompt7), new("8", TypeToEntryType(typeof(T8)), prompt8), }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if ( TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) && TryParseQuickDialog(TypeToEntryType(typeof(T5)), ev.Responses["5"], out var v5) && TryParseQuickDialog(TypeToEntryType(typeof(T6)), ev.Responses["6"], out var v6) && TryParseQuickDialog(TypeToEntryType(typeof(T7)), ev.Responses["7"], out var v7) && TryParseQuickDialog(TypeToEntryType(typeof(T8)), ev.Responses["8"], out var v8) ) okAction.Invoke(v1, v2, v3, v4, v5, v6, v7, v8); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, string prompt5, string prompt6, string prompt7, string prompt8, string prompt9, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2), new("3", TypeToEntryType(typeof(T3)), prompt3), new("4", TypeToEntryType(typeof(T4)), prompt4), new("5", TypeToEntryType(typeof(T5)), prompt5), new("6", TypeToEntryType(typeof(T6)), prompt6), new("7", TypeToEntryType(typeof(T7)), prompt7), new("8", TypeToEntryType(typeof(T8)), prompt8), new("9", TypeToEntryType(typeof(T9)), prompt9), }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if ( TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) && TryParseQuickDialog(TypeToEntryType(typeof(T5)), ev.Responses["5"], out var v5) && TryParseQuickDialog(TypeToEntryType(typeof(T6)), ev.Responses["6"], out var v6) && TryParseQuickDialog(TypeToEntryType(typeof(T7)), ev.Responses["7"], out var v7) && TryParseQuickDialog(TypeToEntryType(typeof(T8)), ev.Responses["8"], out var v8) && TryParseQuickDialog(TypeToEntryType(typeof(T9)), ev.Responses["9"], out var v9) ) okAction.Invoke(v1, v2, v3, v4, v5, v6, v7, v8, v9); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, allowing them to enter in the desired data. /// /// Client to show a dialog for. /// Title of the dialog. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The Nth prompt. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. /// Type of the Nth input. [PublicAPI] public void OpenDialog(ICommonSession session, string title, string prompt1, string prompt2, string prompt3, string prompt4, string prompt5, string prompt6, string prompt7, string prompt8, string prompt9, string prompt10, Action okAction, Action? cancelAction = null) { OpenDialogInternal( session, title, new List { new("1", TypeToEntryType(typeof(T1)), prompt1), new("2", TypeToEntryType(typeof(T2)), prompt2), new("3", TypeToEntryType(typeof(T3)), prompt3), new("4", TypeToEntryType(typeof(T4)), prompt4), new("5", TypeToEntryType(typeof(T5)), prompt5), new("6", TypeToEntryType(typeof(T6)), prompt6), new("7", TypeToEntryType(typeof(T7)), prompt7), new("8", TypeToEntryType(typeof(T8)), prompt8), new("9", TypeToEntryType(typeof(T9)), prompt9), new("10", TypeToEntryType(typeof(T10)), prompt10), }, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if ( TryParseQuickDialog(TypeToEntryType(typeof(T1)), ev.Responses["1"], out var v1) && TryParseQuickDialog(TypeToEntryType(typeof(T2)), ev.Responses["2"], out var v2) && TryParseQuickDialog(TypeToEntryType(typeof(T3)), ev.Responses["3"], out var v3) && TryParseQuickDialog(TypeToEntryType(typeof(T4)), ev.Responses["4"], out var v4) && TryParseQuickDialog(TypeToEntryType(typeof(T5)), ev.Responses["5"], out var v5) && TryParseQuickDialog(TypeToEntryType(typeof(T6)), ev.Responses["6"], out var v6) && TryParseQuickDialog(TypeToEntryType(typeof(T7)), ev.Responses["7"], out var v7) && TryParseQuickDialog(TypeToEntryType(typeof(T8)), ev.Responses["8"], out var v8) && TryParseQuickDialog(TypeToEntryType(typeof(T9)), ev.Responses["9"], out var v9) && TryParseQuickDialog(TypeToEntryType(typeof(T10)), ev.Responses["10"], out var v10) ) okAction.Invoke(v1, v2, v3, v4, v5, v6, v7, v8, v9, v10); else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } /// /// Opens a dialog for the given client, with any amount of entries, allowing them to enter in the desired data. For the truly unhinged. /// /// Client to show a dialog for. /// Title of the dialog. /// List of tuples, not QuickDialogEntries. /// The action to execute upon Ok being pressed. /// The action to execute upon the dialog being cancelled. /// /// Tuple structure for dialogEntries argument: /// Type - int/float/string/LongString/Hex16/VoidOption/null (VoidOption) /// string - prompt text /// object - default value. No checks are performed whether or not it matches the specified type. /// [PublicAPI] public void OpenDialog(ICommonSession session, string title, List<(Type, string, object)> dialogEntries, Action okAction, Action? cancelAction = null) { List _dialogEntries = new(); for(int i = 0; i < dialogEntries.Count; i++) { var (type, prompt, defaultValue) = dialogEntries[i]; _dialogEntries.Add(new QuickDialogEntry((i+1).ToString(), TypeToEntryType(type), prompt??" ", null, defaultValue)); } // ^^^ these "indexes" start with 1, for some reason OpenDialogInternal( session, title, _dialogEntries, QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton, (ev => { if (TryParseQuickDialogList(_dialogEntries, ev.Responses, out var results)) { okAction.Invoke(results!); } else { session.Channel.Disconnect("Replied with invalid quick dialog data."); cancelAction?.Invoke(); } }), cancelAction ?? (() => { }) ); } }