Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pesquisa de Keybinds & Ortografia #51

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion Content.Client/Options/UI/Tabs/KeyRebindTab.xaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
<Control xmlns="https://spacestation14.io"
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:s="clr-namespace:Content.Client.Stylesheets"
xmlns:xNamespace="http://schemas.microsoft.com/winfx/2006/xaml">
<BoxContainer Orientation="Vertical">
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'ui-options-binds-search'}"
Margin="5 0 5 0"
FontColorOverride="{xNamespace:Static s:StyleNano.NanoGold}"
/>
<LineEdit Name="SearchInput" HorizontalExpand="True" SizeFlagsStretchRatio="2"/>
</BoxContainer>
<ScrollContainer VerticalExpand="True">
<BoxContainer Name="KeybindsContainer" Orientation="Vertical" Margin="8 8 8 8">

Expand Down
43 changes: 43 additions & 0 deletions Content.Client/Options/UI/Tabs/KeyRebindTab.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public sealed partial class KeyRebindTab : Control

private readonly List<Action> _deferCommands = new();

private string _searchText = "";

private void HandleToggleUSQWERTYCheckbox(BaseButton.ButtonToggledEventArgs args)
{
_cfg.SetCVar(CVars.DisplayUSQWERTYHotkeys, args.Pressed);
Expand Down Expand Up @@ -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)
Expand All @@ -143,13 +180,19 @@ 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);
}

void AddCheckBox(string checkBoxName, bool currentState, Action<BaseButton.ButtonToggledEventArgs>? callBackOnClick)
{
if (!ShouldDisplayCheckBox(checkBoxName))
return;

CheckBox newCheckBox = new CheckBox() { Text = Loc.GetString(checkBoxName) };
newCheckBox.Pressed = currentState;
newCheckBox.OnToggled += callBackOnClick;
Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/escape-menu/ui/options-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
11 changes: 6 additions & 5 deletions Resources/Locale/pt-BR/escape-menu/ui/options-menu.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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") }

Expand Down Expand Up @@ -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:
Expand All @@ -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...

Expand Down
Loading