Skip to content

Commit

Permalink
Merge pull request #40 from CyberAgentGameEntertainment/feature/fix_s…
Browse files Browse the repository at this point in the history
…earch_bugs

Feature/fix search bugs
  • Loading branch information
Haruma-K authored May 17, 2023
2 parents f2679bf + 8793a60 commit a5a1c5f
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ private string GetText(Item item, int columnIndex)
? "[Missing Reference]"
: item.Rule.AddressableGroup.name;
case Columns.Control:
return item.Rule.Control.ToString();
return item.Rule.Control.Value.ToString();
case Columns.AssetGroups:
if (GetSelection().FirstOrDefault() == item.id)
item.Rule.RefreshAssetGroupDescription();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected override void CellGUI(int columnIndex, Rect cellRect, RowGUIArgs args)
switch ((Columns)columnIndex)
{
case Columns.GroupNameOrAddress:
item.displayName = GetText(item, columnIndex);
item.displayName = GetTextForDisplay(item, columnIndex);
item.icon = errorTypeIcon;
base.CellGUI(columnIndex, cellRect, args);
break;
Expand All @@ -98,10 +98,10 @@ protected override void CellGUI(int columnIndex, Rect cellRect, RowGUIArgs args)
statusIconRect.width = statusIconRect.height;
labelRect.xMin += statusIconRect.width + 2.0f;
GUI.DrawTexture(statusIconRect, errorTypeIcon);
GUI.Label(labelRect, GetText(item, columnIndex));
GUI.Label(labelRect, GetTextForDisplay(item, columnIndex));
break;
case Columns.AssetPath:
GUI.Label(cellRect, GetText(item, columnIndex));
GUI.Label(cellRect, GetTextForDisplay(item, columnIndex));
break;
case Columns.Labels:
DrawBadges(entryItem.Entry.Labels, new Vector2(cellRect.x, cellRect.y + 1),
Expand Down Expand Up @@ -162,9 +162,25 @@ string KeySelector(TreeViewItem x)
: items.OrderByDescending(KeySelector, Comparer<string>.Create(EditorUtility.NaturalCompare));
}

private string GetTextForDisplay(TreeViewItem item, int columnIndex)
{
return hasSearch ? GetTextForSearch(item, columnIndex) : GetText(item, columnIndex);
}

protected override string GetTextForSearch(TreeViewItem item, int columnIndex)
{
return GetText(item, columnIndex);
// GroupItem is not a search target.
if (item is GroupItem)
return null;

if (columnIndex != (int)Columns.GroupNameOrAddress)
return GetText(item, columnIndex);

var groupItem = item.parent;
var groupText = GetText(groupItem, columnIndex);
var entryText = GetText(item, columnIndex);
return $"[{groupText}] {entryText}";

}

protected override bool CanMultiSelect(TreeViewItem item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ protected override void SelectionChanged(IList<int> selectedIds)

private bool DoesCellMatchSearch(TreeViewItem item, int columnIndex, string search)
{
return GetTextForSearch(item, columnIndex).IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
var text = GetTextForSearch(item, columnIndex);
if (string.IsNullOrEmpty(text))
return false;
return text.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
}

protected override TreeViewItem BuildRoot()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@ public string OnToolbarGUI(Rect rect)
foreach (var targetColumn in _targetColumns)
{
var columnName = targetColumn.Value;

// If the columnName contains a slash, replace it with the Unicode slash \u2215.
// Otherwise, the slash will be recognized as a menu hierarchy separator.
// https://answers.unity.com/questions/398495/can-genericmenu-item-content-display-.html
columnName = columnName.Replace("/", "\u2215");

var index = targetColumn.Key;
menu.AddItem(new GUIContent(columnName), _selectedColumnIndex == index, () =>
{
Expand Down
6 changes: 3 additions & 3 deletions Packages/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"dependencies": {
"com.unity.addressables": "1.18.19",
"com.unity.collab-proxy": "1.15.17",
"com.unity.ide.rider": "2.0.7",
"com.unity.ide.visualstudio": "2.0.15",
"com.unity.collab-proxy": "1.17.2",
"com.unity.ide.rider": "3.0.15",
"com.unity.ide.visualstudio": "2.0.16",
"com.unity.ide.vscode": "1.2.5",
"com.unity.test-framework": "1.1.31",
"com.unity.textmeshpro": "3.0.6",
Expand Down
8 changes: 4 additions & 4 deletions Packages/packages-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "1.15.17",
"version": "1.17.2",
"depth": 0,
"source": "registry",
"dependencies": {
Expand All @@ -31,16 +31,16 @@
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "2.0.7",
"version": "3.0.15",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.test-framework": "1.1.1"
"com.unity.ext.nunit": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.15",
"version": "2.0.16",
"depth": 0,
"source": "registry",
"dependencies": {
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
m_EditorVersion: 2020.3.35f1
m_EditorVersionWithRevision: 2020.3.35f1 (18e4db7a9996)
m_EditorVersion: 2020.3.40f1
m_EditorVersionWithRevision: 2020.3.40f1 (ba48d4efcef1)

0 comments on commit a5a1c5f

Please sign in to comment.