Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
fix: click the sidebar will quit from searching result.
Browse files Browse the repository at this point in the history
  • Loading branch information
ArchiDog1998 committed Aug 19, 2023
1 parent 2058198 commit a7ec210
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions RotationSolver/UI/RotationConfigWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ private void DrawSideBar()
if (ImGuiHelper.NoPaddingNoColorImageButton(icon.ImGuiHandle, Vector2.One * iconSize, item.ToString()))
{
_activeTab = item;
_searchResults = Array.Empty<ISearchable>();
}
ImGuiHelper.DrawActionOverlay(cursor, iconSize, _activeTab == item ? 1 : 0);
}, Math.Max(_scale * MIN_COLUMN_WIDTH, wholeWidth), iconSize);
Expand All @@ -183,6 +184,7 @@ private void DrawSideBar()
if (ImGui.Selectable(item.ToString(), _activeTab == item, ImGuiSelectableFlags.None, new Vector2(0, 20)))
{
_activeTab = item;
_searchResults = Array.Empty<ISearchable>();
}
if (ImGui.IsItemHovered())
{
Expand Down Expand Up @@ -258,6 +260,7 @@ private void DrawHeader(float wholeWidth)
_activeTab == RotationConfigWindowTab.About, "About Icon"))
{
_activeTab = RotationConfigWindowTab.About;
_searchResults = Array.Empty<ISearchable>();
}
ImguiTooltips.HoveredTooltip(LocalizationManager.RightLang.ConfigWindow_About_Punchline);

Expand Down Expand Up @@ -335,6 +338,7 @@ private void DrawRotationIcon(ICustomRotation rotation, float iconSize)
Vector2.One * iconSize, _activeTab == RotationConfigWindowTab.Rotation))
{
_activeTab = RotationConfigWindowTab.Rotation;
_searchResults = Array.Empty<ISearchable>();
}
var desc = rotation.Name + $" ({rotation.RotationName})";
if (!string.IsNullOrEmpty(rotation.Description)) desc += "\n \n" + rotation.Description;
Expand Down
5 changes: 3 additions & 2 deletions RotationSolver/UI/RotationConfigWindow_Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ public partial class RotationConfigWindow
internal static float Similarity(string text, string key)
{
var chars = text.Split(new char[] { ' ', ',', '、', '.', '。' }, StringSplitOptions.RemoveEmptyEntries);
var keys = key.Split(new char[] { ' ', ',', '、', '.', '。' }, StringSplitOptions.RemoveEmptyEntries);

var startWithCount = chars.Count(i => i.StartsWith(key, StringComparison.OrdinalIgnoreCase));
var startWithCount = chars.Count(i => keys.Any(k => i.StartsWith(k, StringComparison.OrdinalIgnoreCase)));

var containCount = chars.Count(i => i.Contains(key, StringComparison.OrdinalIgnoreCase));
var containCount = chars.Count(i => keys.Any(k => i.Contains(k, StringComparison.OrdinalIgnoreCase)));

return startWithCount * 3 + containCount;
}
Expand Down

0 comments on commit a7ec210

Please sign in to comment.