From 7befd1d8cc40515ff79147bf2a1b6a2f2e669744 Mon Sep 17 00:00:00 2001 From: 21Melkuu <79728504+21Melkuu@users.noreply.github.com> Date: Mon, 2 Dec 2024 11:46:01 +0300 Subject: [PATCH 1/5] com --- .../SS220/RenameOnStart/RenameOnStartWindow.xaml | 5 +++++ .../RenameOnStart/RenameOnStartWindow.xaml.cs | 15 +++++++++++++++ 2 files changed, 20 insertions(+) create mode 100644 Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml create mode 100644 Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs diff --git a/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml b/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml new file mode 100644 index 00000000000000..0d72b5c488fb37 --- /dev/null +++ b/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml @@ -0,0 +1,5 @@ + + + diff --git a/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs b/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs new file mode 100644 index 00000000000000..3da81c375c2919 --- /dev/null +++ b/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs @@ -0,0 +1,15 @@ +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client.SS220.RenameOnStart; + +[GenerateTypedNameReferences] +public sealed partial class RenameOnStartWindow : Control +{ + public RenameOnStartWindow() + { + RobustXamlLoader.Load(this); + } +} + From 2d741a14b7629a45353abdf06ed872e263c763c4 Mon Sep 17 00:00:00 2001 From: 21Melkuu <79728504+21Melkuu@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:31:34 +0300 Subject: [PATCH 2/5] shitcode --- .../SS220/RenameOnStart/RenameOnStartWindow.xaml | 5 ----- .../RenameOnStart/RenameOnStartWindow.xaml.cs | 15 --------------- 2 files changed, 20 deletions(-) delete mode 100644 Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml delete mode 100644 Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs diff --git a/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml b/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml deleted file mode 100644 index 0d72b5c488fb37..00000000000000 --- a/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml +++ /dev/null @@ -1,5 +0,0 @@ - - - diff --git a/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs b/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs deleted file mode 100644 index 3da81c375c2919..00000000000000 --- a/Content.Client/SS220/RenameOnStart/RenameOnStartWindow.xaml.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Robust.Client.AutoGenerated; -using Robust.Client.UserInterface; -using Robust.Client.UserInterface.XAML; - -namespace Content.Client.SS220.RenameOnStart; - -[GenerateTypedNameReferences] -public sealed partial class RenameOnStartWindow : Control -{ - public RenameOnStartWindow() - { - RobustXamlLoader.Load(this); - } -} - From aed12cdb3c67b7ee57c227163f68e912cf35736e Mon Sep 17 00:00:00 2001 From: 21Melkuu <79728504+21Melkuu@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:31:48 +0300 Subject: [PATCH 3/5] shitcode) --- .../DialogWindowDescUI/DialogWindowDesc.xaml | 20 +++++ .../DialogWindowDesc.xaml.cs | 83 +++++++++++++++++++ .../SS220/QuickDialog/QuickDialogSystem.cs | 35 ++++++++ .../QuickDialogSystem.OpenDialog.cs | 29 +++++++ .../Administration/QuickDialogSystem.cs | 22 +++++ .../SS220/RenameStart/RenameStartComponent.cs | 15 ++++ .../SS220/RenameStart/RenameStartSystem.cs | 67 +++++++++++++++ .../Administration/QuickDialogOpenEvent.cs | 40 +++++++++ .../ru-RU/ss220/quick-dialog/quick-dialog.ftl | 1 + .../rename-start-window.ftl | 7 ++ .../Prototypes/Roles/Jobs/Civilian/clown.yml | 1 + .../Prototypes/Roles/Jobs/Civilian/mime.yml | 1 + .../Prototypes/Roles/Jobs/Science/borg.yml | 8 ++ 13 files changed, 329 insertions(+) create mode 100644 Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml create mode 100644 Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs create mode 100644 Content.Client/SS220/QuickDialog/QuickDialogSystem.cs create mode 100644 Content.Server/SS220/RenameStart/RenameStartComponent.cs create mode 100644 Content.Server/SS220/RenameStart/RenameStartSystem.cs create mode 100644 Resources/Locale/ru-RU/ss220/quick-dialog/quick-dialog.ftl create mode 100644 Resources/Locale/ru-RU/ss220/rename-start-window/rename-start-window.ftl diff --git a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml new file mode 100644 index 00000000000000..92b2ac1da22cba --- /dev/null +++ b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + diff --git a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs new file mode 100644 index 00000000000000..9058f9d3a1c636 --- /dev/null +++ b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs @@ -0,0 +1,83 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Shared.Administration; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.CustomControls; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client.SS220.DialogWindowDescUI; + +[GenerateTypedNameReferences] +public sealed partial class DialogWindowDesc : DefaultWindow +{ + private List<(string, LineEdit)> _promptLines; + + private bool _finished; + + public Action>? OnConfirmed; + + public Action? OnCancelled; + + public DialogWindowDesc(string title, string dsscEntty, List entries, bool ok = true) + { + RobustXamlLoader.Load(this); + + Title = title; + + OkButton.Visible = ok; + + _promptLines = new(entries.Count); + + for (int i = 0; i < entries.Count; i++) + { + var entry = entries[i]; + + var box = new BoxContainer(); + box.AddChild(new Label() { Text = entry.Prompt, Align = Label.AlignMode.Center, HorizontalExpand = true}); + Prompts.AddChild(box); + + var boxDesc = new BoxContainer(); + boxDesc.AddChild(new Label() { Text = dsscEntty, Align = Label.AlignMode.Center, FontColorOverride = Color.Gray, HorizontalExpand = true }); + Prompts.AddChild(boxDesc); + + var boxEmpty = new BoxContainer(); + boxEmpty.AddChild(new BoxContainer() {MinHeight=20}); + Prompts.AddChild(boxEmpty); + + var boxEdit = new BoxContainer(); + var edit = new LineEdit() { HorizontalExpand = true }; + boxEdit.AddChild(edit); + + _promptLines.Add((entry.FieldId, edit)); + Prompts.AddChild(boxEdit); + } + + OkButton.OnPressed += _ => Confirm(); + + OnClose += () => + { + if (!_finished) + OnCancelled?.Invoke(); + }; + + _promptLines[0].Item2.GrabKeyboardFocus(); + + MinWidth *= 2; // Just double it. + + OpenCentered(); + } + + private void Confirm() + { + var results = new Dictionary(); + foreach (var (field, edit) in _promptLines) + { + results[field] = edit.Text; + } + + _finished = true; + OnConfirmed?.Invoke(results); + Close(); + } +} + diff --git a/Content.Client/SS220/QuickDialog/QuickDialogSystem.cs b/Content.Client/SS220/QuickDialog/QuickDialogSystem.cs new file mode 100644 index 00000000000000..44d9a3e3898033 --- /dev/null +++ b/Content.Client/SS220/QuickDialog/QuickDialogSystem.cs @@ -0,0 +1,35 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Client.SS220.DialogWindowDescUI; +using Content.Shared.Administration; + +namespace Content.Client.SS220.QuickDialog; + +public sealed class QuickDialogSystem : EntitySystem +{ + /// + public override void Initialize() + { + SubscribeNetworkEvent(OpenDialog); + } + + private void OpenDialog(QuickDialogDescOpenEvent ev) + { + var ok = (ev.Buttons & QuickDialogButtonFlag.OkButton) != 0; + var window = new DialogWindowDesc(ev.Title, ev.Description, ev.Prompts, ok: ok); + + window.OnConfirmed += responses => + { + RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId, + responses, + QuickDialogButtonFlag.OkButton)); + }; + + window.OnCancelled += () => + { + RaiseNetworkEvent(new QuickDialogResponseEvent(ev.DialogId, + new(), + QuickDialogButtonFlag.CancelButton)); + }; + } +} + diff --git a/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs b/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs index 1bbc8a6c9e8710..399a937a9bb20d 100644 --- a/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs +++ b/Content.Server/Administration/QuickDialogSystem.OpenDialog.cs @@ -173,4 +173,33 @@ public void OpenDialog(ICommonSession session, string title, str cancelAction ?? (() => { }) ); } + + //SS220-RenameStart - start + [PublicAPI] + public void OpenDialog(ICommonSession session, string title, string description, string prompt, Action okAction, + Action? cancelAction = null) + { + OpenDialogInternal( + session, + title, + description, + 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 ?? (() => { }) + ); + } + //SS220-RenameStart - end } diff --git a/Content.Server/Administration/QuickDialogSystem.cs b/Content.Server/Administration/QuickDialogSystem.cs index df2953f98d19b0..d149e7e9b22b4d 100644 --- a/Content.Server/Administration/QuickDialogSystem.cs +++ b/Content.Server/Administration/QuickDialogSystem.cs @@ -103,6 +103,28 @@ private void OpenDialogInternal(ICommonSession session, string title, List entries, QuickDialogButtonFlag buttons, Action okAction, Action cancelAction) + { + var did = GetDialogId(); + RaiseNetworkEvent( + new QuickDialogDescOpenEvent( + title, + description, + entries, + did, + buttons), + session + ); + + _openDialogs.Add(did, (okAction, cancelAction)); + if (!_openDialogsByUser.ContainsKey(session.UserId)) + _openDialogsByUser.Add(session.UserId, new List()); + + _openDialogsByUser[session.UserId].Add(did); + } + //SS220-RenameStart - end + private bool TryParseQuickDialog(QuickDialogEntryType entryType, string input, [NotNullWhen(true)] out T? output) { switch (entryType) diff --git a/Content.Server/SS220/RenameStart/RenameStartComponent.cs b/Content.Server/SS220/RenameStart/RenameStartComponent.cs new file mode 100644 index 00000000000000..e0da56edf19ce7 --- /dev/null +++ b/Content.Server/SS220/RenameStart/RenameStartComponent.cs @@ -0,0 +1,15 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +namespace Content.Server.SS220.RenameStart; + +/// +/// This is used for change the entity name once the player starts controlling +/// +[RegisterComponent] +public sealed partial class RenameStartComponent : Component +{ + [DataField] + public int MinChar = 2; + + [DataField] + public int MaxChar = 36; +} diff --git a/Content.Server/SS220/RenameStart/RenameStartSystem.cs b/Content.Server/SS220/RenameStart/RenameStartSystem.cs new file mode 100644 index 00000000000000..e6d6952559182e --- /dev/null +++ b/Content.Server/SS220/RenameStart/RenameStartSystem.cs @@ -0,0 +1,67 @@ +// © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using System.Text.RegularExpressions; +using Content.Server.Administration; +using Content.Server.Administration.Systems; +using Content.Shared.Administration; +using Robust.Shared.Player; + +namespace Content.Server.SS220.RenameStart; + +/// +/// This handles opens the ui to change your name at the beginning of the game. Renaming is necessary for such roles as a clown with a “custom” name +/// +public sealed class RenameStartSystem : EntitySystem +{ + [Dependency] private readonly QuickDialogSystem _quickDialog = default!; + [Dependency] private readonly MetaDataSystem _meta = default!; + [Dependency] private readonly AdminFrozenSystem _frozen = default!; + private static readonly Regex Expressions = new("[^А-Яа-яёЁ0-9' \\-?!,.]"); + /// + public override void Initialize() + { + SubscribeLocalEvent(OnPlayerAttached); + } + + private void OnPlayerAttached(Entity ent, ref PlayerAttachedEvent args) + { + _frozen.FreezeAndMute(ent.Owner); //prevent players from changing their name after showing up with their initial name + + ChangeName(ent.Owner); + } + + private void ChangeName(EntityUid entOwner) + { + if(!TryComp(entOwner, out var actorComp)) + return; + + if(!TryComp(entOwner, out var renameComp)) + return; + + _quickDialog.OpenDialog(actorComp.PlayerSession, + Loc.GetString("rename-window-title"), + description: Loc.GetString("rename-window-desc"), + Loc.GetString("rename-window-promt"), + (LongString newName) => + { + if (newName.String.Length <= renameComp.MinChar || + newName.String.Length >= renameComp.MaxChar || + Expressions.IsMatch(newName.String)) + { + ChangeName(entOwner); + return; + } + + _meta.SetEntityName(entOwner, newName); + + RemComp(entOwner); + + RemComp(entOwner); + + }, () => + { + RemComp(entOwner); + + RemComp(entOwner); + }); + } +} diff --git a/Content.Shared/Administration/QuickDialogOpenEvent.cs b/Content.Shared/Administration/QuickDialogOpenEvent.cs index f4e77ab9990adb..01388e41bcff87 100644 --- a/Content.Shared/Administration/QuickDialogOpenEvent.cs +++ b/Content.Shared/Administration/QuickDialogOpenEvent.cs @@ -37,6 +37,46 @@ public QuickDialogOpenEvent(string title, List prompts, int di } } +//SS220-RenameStart - start +[Serializable, NetSerializable] +public sealed class QuickDialogDescOpenEvent : EntityEventArgs +{ + /// + /// The title of the dialog. + /// + public string Title; + + /// + /// The title of the dialog. + /// + public string Description; + + /// + /// The internal dialog ID. + /// + public int DialogId; + + /// + /// The prompts to show the user. + /// + public List Prompts; + + /// + /// The buttons presented for the user. + /// + public QuickDialogButtonFlag Buttons = QuickDialogButtonFlag.OkButton | QuickDialogButtonFlag.CancelButton; + + public QuickDialogDescOpenEvent(string title, string description, List prompts, int dialogId, QuickDialogButtonFlag buttons) + { + Title = title; + Description = description; + Prompts = prompts; + Buttons = buttons; + DialogId = dialogId; + } +} +//SS220-RenameStart - end + /// /// A networked event raised when the client replies to a quick dialog. /// diff --git a/Resources/Locale/ru-RU/ss220/quick-dialog/quick-dialog.ftl b/Resources/Locale/ru-RU/ss220/quick-dialog/quick-dialog.ftl new file mode 100644 index 00000000000000..094b56626380d2 --- /dev/null +++ b/Resources/Locale/ru-RU/ss220/quick-dialog/quick-dialog.ftl @@ -0,0 +1 @@ +quick-dialog-ui-confirm = Подтвердить \ No newline at end of file diff --git a/Resources/Locale/ru-RU/ss220/rename-start-window/rename-start-window.ftl b/Resources/Locale/ru-RU/ss220/rename-start-window/rename-start-window.ftl new file mode 100644 index 00000000000000..f81c09034112f6 --- /dev/null +++ b/Resources/Locale/ru-RU/ss220/rename-start-window/rename-start-window.ftl @@ -0,0 +1,7 @@ +rename-window-title = Переименование +rename-window-promt = Выберите свое новое имя +rename-window-desc = + Ваше имя не должно нарушать 4 пункт правил: + Ваш персонаж - находится на передовой космической станции. + Клоуну и миму предоставляется более широкое поле для мемных имён + Имена синтетиков так же имеют свою специфику. Ознакомьтесь с ними на вики. \ No newline at end of file diff --git a/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml b/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml index c84f9079e566e9..2b05a04f3b93b6 100644 --- a/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml +++ b/Resources/Prototypes/Roles/Jobs/Civilian/clown.yml @@ -18,6 +18,7 @@ special: - !type:AddComponentSpecial components: + - type: RenameStart #SS220-RenameStart - type: Clumsy clumsyDamage: types: #literally just picked semi random valus. i tested this once and tweaked it. diff --git a/Resources/Prototypes/Roles/Jobs/Civilian/mime.yml b/Resources/Prototypes/Roles/Jobs/Civilian/mime.yml index 4eb4e8151ce258..03b7cf756dba23 100644 --- a/Resources/Prototypes/Roles/Jobs/Civilian/mime.yml +++ b/Resources/Prototypes/Roles/Jobs/Civilian/mime.yml @@ -20,6 +20,7 @@ components: - type: MimePowers - type: FrenchAccent + - type: RenameStart #SS220-RenameStart - type: startingGear id: MimeGear diff --git a/Resources/Prototypes/Roles/Jobs/Science/borg.yml b/Resources/Prototypes/Roles/Jobs/Science/borg.yml index f3b3b6dff5ddf2..1f4141dce9d06d 100644 --- a/Resources/Prototypes/Roles/Jobs/Science/borg.yml +++ b/Resources/Prototypes/Roles/Jobs/Science/borg.yml @@ -18,6 +18,10 @@ supervisors: job-supervisors-rd jobEntity: StationAiBrain applyTraits: false + special: + - !type:AddComponentSpecial + components: + - type: RenameStart #SS220-RenameStart - type: job id: Borg @@ -32,3 +36,7 @@ supervisors: job-supervisors-rd jobEntity: PlayerBorgGeneric applyTraits: false + special: + - !type:AddComponentSpecial + components: + - type: RenameStart #SS220-RenameStart \ No newline at end of file From 1bf22ffce10257a52c83c47957b1e1149a136abf Mon Sep 17 00:00:00 2001 From: 21Melkuu <79728504+21Melkuu@users.noreply.github.com> Date: Sat, 14 Dec 2024 22:21:59 +0300 Subject: [PATCH 4/5] rev --- .../DialogWindowDescUI/DialogWindowDesc.xaml | 8 ++-- .../DialogWindowDesc.xaml.cs | 11 +++--- .../SS220/RenameStart/RenameStartComponent.cs | 4 +- .../SS220/RenameStart/RenameStartSystem.cs | 37 +++++++++++++++---- .../Prototypes/Roles/Jobs/Science/borg.yml | 8 ++-- 5 files changed, 47 insertions(+), 21 deletions(-) diff --git a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml index 92b2ac1da22cba..e60873ef950d35 100644 --- a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml +++ b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml @@ -1,6 +1,8 @@ - + - + diff --git a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs index 9058f9d3a1c636..8fc5dfeb705ceb 100644 --- a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs +++ b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs @@ -2,13 +2,16 @@ using Content.Shared.Administration; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.XAML; +using Content.Client.UserInterface.Controls; namespace Content.Client.SS220.DialogWindowDescUI; +/// +/// A modified window in which you can send an additional description to explain a particular action being performed +/// [GenerateTypedNameReferences] -public sealed partial class DialogWindowDesc : DefaultWindow +public sealed partial class DialogWindowDesc : FancyWindow { private List<(string, LineEdit)> _promptLines; @@ -60,10 +63,6 @@ public DialogWindowDesc(string title, string dsscEntty, List e OnCancelled?.Invoke(); }; - _promptLines[0].Item2.GrabKeyboardFocus(); - - MinWidth *= 2; // Just double it. - OpenCentered(); } diff --git a/Content.Server/SS220/RenameStart/RenameStartComponent.cs b/Content.Server/SS220/RenameStart/RenameStartComponent.cs index e0da56edf19ce7..b94ce6e94927f5 100644 --- a/Content.Server/SS220/RenameStart/RenameStartComponent.cs +++ b/Content.Server/SS220/RenameStart/RenameStartComponent.cs @@ -1,4 +1,6 @@ // © SS220, An EULA/CLA with a hosting restriction, full text: https://raw.githubusercontent.com/SerbiaStrong-220/space-station-14/master/CLA.txt +using Content.Shared.Preferences; + namespace Content.Server.SS220.RenameStart; /// @@ -11,5 +13,5 @@ public sealed partial class RenameStartComponent : Component public int MinChar = 2; [DataField] - public int MaxChar = 36; + public int MaxChar = HumanoidCharacterProfile.MaxNameLength; } diff --git a/Content.Server/SS220/RenameStart/RenameStartSystem.cs b/Content.Server/SS220/RenameStart/RenameStartSystem.cs index e6d6952559182e..b09f76a0bef94a 100644 --- a/Content.Server/SS220/RenameStart/RenameStartSystem.cs +++ b/Content.Server/SS220/RenameStart/RenameStartSystem.cs @@ -3,6 +3,8 @@ using Content.Server.Administration; using Content.Server.Administration.Systems; using Content.Shared.Administration; +using Content.Shared.Mind; +using Content.Shared.Mind.Components; using Robust.Shared.Player; namespace Content.Server.SS220.RenameStart; @@ -20,6 +22,7 @@ public sealed class RenameStartSystem : EntitySystem public override void Initialize() { SubscribeLocalEvent(OnPlayerAttached); + SubscribeLocalEvent(OnRemoveComponent); } private void OnPlayerAttached(Entity ent, ref PlayerAttachedEvent args) @@ -32,10 +35,16 @@ private void OnPlayerAttached(Entity ent, ref PlayerAttach private void ChangeName(EntityUid entOwner) { if(!TryComp(entOwner, out var actorComp)) + { + RemComp(entOwner); return; + } if(!TryComp(entOwner, out var renameComp)) + { + RemComp(entOwner); return; + } _quickDialog.OpenDialog(actorComp.PlayerSession, Loc.GetString("rename-window-title"), @@ -43,25 +52,39 @@ private void ChangeName(EntityUid entOwner) Loc.GetString("rename-window-promt"), (LongString newName) => { - if (newName.String.Length <= renameComp.MinChar || - newName.String.Length >= renameComp.MaxChar || + if (newName.String.Length < renameComp.MinChar || + newName.String.Length > renameComp.MaxChar || Expressions.IsMatch(newName.String)) { ChangeName(entOwner); return; } - _meta.SetEntityName(entOwner, newName); + if(!TryComp(entOwner, out var mindContComp)) + { + RemComp(entOwner); + return; + } - RemComp(entOwner); + if (!TryComp(mindContComp.Mind, out var mindComp)) + { + RemComp(entOwner); + return; + } - RemComp(entOwner); + mindComp.CharacterName = newName.String; + _meta.SetEntityName(entOwner, newName); + + RemComp(entOwner); }, () => { - RemComp(entOwner); - RemComp(entOwner); }); } + + private void OnRemoveComponent(Entity ent, ref ComponentShutdown args) + { + RemComp(ent.Owner); + } } diff --git a/Resources/Prototypes/Roles/Jobs/Science/borg.yml b/Resources/Prototypes/Roles/Jobs/Science/borg.yml index 1f4141dce9d06d..01f30536b7105a 100644 --- a/Resources/Prototypes/Roles/Jobs/Science/borg.yml +++ b/Resources/Prototypes/Roles/Jobs/Science/borg.yml @@ -18,10 +18,10 @@ supervisors: job-supervisors-rd jobEntity: StationAiBrain applyTraits: false - special: + special: #SS220-RenameStart - start - !type:AddComponentSpecial components: - - type: RenameStart #SS220-RenameStart + - type: RenameStart #SS220-RenameStart - end - type: job id: Borg @@ -36,7 +36,7 @@ supervisors: job-supervisors-rd jobEntity: PlayerBorgGeneric applyTraits: false - special: + special: #SS220-RenameStart - start - !type:AddComponentSpecial components: - - type: RenameStart #SS220-RenameStart \ No newline at end of file + - type: RenameStart #SS220-RenameStart - end \ No newline at end of file From 323c5af882dbf3b2b31d81ae765d014d3103f556 Mon Sep 17 00:00:00 2001 From: 21Melkuu <79728504+21Melkuu@users.noreply.github.com> Date: Sun, 15 Dec 2024 03:57:52 +0300 Subject: [PATCH 5/5] Fixik --- .../SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs index 8fc5dfeb705ceb..05f29b4a1e39a1 100644 --- a/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs +++ b/Content.Client/SS220/DialogWindowDescUI/DialogWindowDesc.xaml.cs @@ -63,6 +63,8 @@ public DialogWindowDesc(string title, string dsscEntty, List e OnCancelled?.Invoke(); }; + _promptLines[0].Item2.GrabKeyboardFocus(); + OpenCentered(); }