From 8391f81484b5ad3983bb0f80371dcf5c4a53e1ef Mon Sep 17 00:00:00 2001 From: TheLife Date: Tue, 10 Dec 2024 11:42:02 -0300 Subject: [PATCH] Pesquisa de Keybinds & Ortografia --- .../Options/UI/Tabs/KeyRebindTab.xaml | 11 ++++- .../Options/UI/Tabs/KeyRebindTab.xaml.cs | 43 +++++++++++++++++++ .../en-US/escape-menu/ui/options-menu.ftl | 1 + .../pt-BR/escape-menu/ui/options-menu.ftl | 11 ++--- 4 files changed, 60 insertions(+), 6 deletions(-) diff --git a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml index 93859099eeb..0264caf879e 100644 --- a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml +++ b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml @@ -1,6 +1,15 @@  + xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" + xmlns:s="clr-namespace:Content.Client.Stylesheets" + xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml"> + + diff --git a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs index d911cc93dca..7222e048d37 100644 --- a/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs +++ b/Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs @@ -36,6 +36,8 @@ public sealed partial class KeyRebindTab : Control private readonly List _deferCommands = new(); + private string _searchText = ""; + private void HandleToggleUSQWERTYCheckbox(BaseButton.ButtonToggledEventArgs args) { _cfg.SetCVar(CVars.DisplayUSQWERTYHotkeys, args.Pressed); @@ -123,8 +125,43 @@ public KeyRebindTab() }); }; + SearchInput.OnTextChanged += _ => + { + _searchText = SearchInput.Text.TrimStart(); + PopulateOptions(); + }; + + PopulateOptions(); + } + + private void PopulateOptions() + { + KeybindsContainer.RemoveAllChildren(); + _keyControls.Clear(); var first = true; + bool ShouldDisplayButton(BoundKeyFunction function) + { + if (_searchText == string.Empty) + return true; + + var optionText = + Loc.GetString($"ui-options-function-{CaseConversion.PascalToKebab(function.FunctionName)}"); + return optionText.StartsWith(_searchText, StringComparison.OrdinalIgnoreCase) + || _searchText.Contains(optionText, StringComparison.OrdinalIgnoreCase); + + } + + bool ShouldDisplayCheckBox(string checkBoxName) + { + if (_searchText == string.Empty) + return true; + + var optionText = Loc.GetString(checkBoxName); + return optionText.StartsWith(_searchText, StringComparison.OrdinalIgnoreCase) + || _searchText.Contains(optionText, StringComparison.OrdinalIgnoreCase); + } + void AddHeader(string headerContents) { if (!first) @@ -143,6 +180,9 @@ void AddHeader(string headerContents) void AddButton(BoundKeyFunction function) { + if (!ShouldDisplayButton(function)) + return; + var control = new KeyControl(this, function); KeybindsContainer.AddChild(control); _keyControls.Add(function, control); @@ -150,6 +190,9 @@ void AddButton(BoundKeyFunction function) void AddCheckBox(string checkBoxName, bool currentState, Action? callBackOnClick) { + if (!ShouldDisplayCheckBox(checkBoxName)) + return; + CheckBox newCheckBox = new CheckBox() { Text = Loc.GetString(checkBoxName) }; newCheckBox.Pressed = currentState; newCheckBox.OnToggled += callBackOnClick; diff --git a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl index 5b43bf4405d..1252c2c16b7 100644 --- a/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl +++ b/Resources/Locale/en-US/escape-menu/ui/options-menu.ftl @@ -101,6 +101,7 @@ ui-options-hud-layout = HUD layout: ui-options-binds-reset-all = Reset ALL keybinds ui-options-binds-explanation = Click to change binding, right-click to clear +ui-options-binds-search = Search ui-options-unbound = Unbound ui-options-bind-reset = Reset ui-options-key-prompt = Press a key... diff --git a/Resources/Locale/pt-BR/escape-menu/ui/options-menu.ftl b/Resources/Locale/pt-BR/escape-menu/ui/options-menu.ftl index 9d80b6a77f5..696d3fe15b3 100644 --- a/Resources/Locale/pt-BR/escape-menu/ui/options-menu.ftl +++ b/Resources/Locale/pt-BR/escape-menu/ui/options-menu.ftl @@ -10,7 +10,7 @@ ui-options-tab-misc = Geral ui-options-apply = Salvar & Aplicar ui-options-reset-all = Resetar mudanca -ui-options-default = Resetar ao padrao +ui-options-default = Resetar ao padrão ui-options-value-percent = { TOSTRING($value, "P0") } @@ -70,14 +70,14 @@ ui-options-scale-150 = 150% ui-options-scale-175 = 175% ui-options-scale-200 = 200% ui-options-hud-theme = Tema do HUD: -ui-options-hud-theme-default = Padrao +ui-options-hud-theme-default = Padrão ui-options-hud-theme-plasmafire = Plasmafire ui-options-hud-theme-slimecore = Slimecore ui-options-hud-theme-clockwork = Clockwork ui-options-hud-theme-retro = Retro ui-options-hud-theme-minimalist = Minimalista ui-options-hud-theme-ashen = Ashen -ui-options-hud-layout-default = Padrao (SS14) +ui-options-hud-layout-default = Padrão (SS14) ui-options-hud-layout-separated = Separado (SS13) ui-options-vp-stretch = Esticar a viewport para caber na janela do jogo ui-options-vp-scale = Escala da viewport fixa: @@ -100,8 +100,9 @@ ui-options-hud-layout = Layout do HUD: ## Controls menu ui-options-binds-reset-all = Redefinir TODOS os atalhos de teclado -ui-options-binds-explanation = Clique para alterar a vinculacao, clique com o botao direito para limpar -ui-options-unbound = Desatribuido +ui-options-binds-explanation = Clique para definir uma tecla, clique com o botão direito para limpar +ui-options-binds-search = Pesquisar +ui-options-unbound = Não definido ui-options-bind-reset = Resetar ui-options-key-prompt = Pressione uma tecla...