Skip to content
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
3 changes: 2 additions & 1 deletion src/Dialogs/DialogHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public static void RenderActiveWindows()

public static void ShowException(Exception ex)
{
string message = ex.Message.Replace("'", "");
// Replace both ' and " with nothing. Messages with these values cause INVALID MESSAGE WITH QUOTES
string message = ex.Message.Replace("'", "").Replace("\"", "");

Clipboard.SetText($"{ex.Message} \n{ex.StackTrace}");
TinyFileDialog.MessageBoxErrorOk($"{message} Details copied to clipboard!");
Expand Down
28 changes: 23 additions & 5 deletions src/DockedWindows/AssetWindow/AssetViewWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -515,19 +515,32 @@ private string TextEplislon(string text, float textWidth, float itemWidth)

#region Asset Loading

/// <summary>
/// Filters assets based on its visibility and some search term.
/// </summary>
/// <param name="assets">Full list of assets</param>
/// <returns>Filtered list of assets</returns>
private List<AssetItem> UpdateSearch(List<AssetItem> assets)
{
List<AssetItem> filtered = new List<AssetItem>();
for (int i = 0; i < assets.Count; i++)
{
bool HasText = assets[i].Name != null &&
assets[i].Name.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;

if (!assets[i].Visible)
// Not visible
continue;

if (isSearch && HasText || !isSearch)
filtered.Add(assets[i]);
if (isSearch)
{
// Search for matches if filtering is applied
bool hasText = assets[i].Name != null &&
assets[i].Name.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;

hasText |= assets[i].Aliases.Any(s => s.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0);

if (!hasText)
continue;
}
filtered.Add(assets[i]);
}
return filtered;
}
Expand Down Expand Up @@ -667,6 +680,11 @@ public class AssetItem

public string DisplayName { get; internal set; }

/// <summary>
/// Aliases of the asset, which are also valid search terms
/// </summary>
public string[] Aliases { get; set; } = Array.Empty<string>();

/// <summary>
/// The image ID of the icon.
/// </summary>
Expand Down
18 changes: 4 additions & 14 deletions src/DockedWindows/Outliner/Outliner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,7 @@ public void ScrollToSelected(NodeBase target)

private bool GetNodePosition(NodeBase target, NodeBase parent, ref float pos, float itemHeight)
{
bool HasText = parent.Header != null &&
parent.Header.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;
bool HasText = parent.IsNameMatch(_searchText);

//Search is active and node is found but is not in results so skip scrolling
if (isSearch && parent == target && !HasText)
Expand Down Expand Up @@ -303,8 +302,7 @@ private void SetupNodes(NodeBase node)

private void CalculateCount(NodeBase node, ref int counter)
{
bool HasText = node.Header != null &&
node.Header.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;
bool HasText = node.IsNameMatch(_searchText);

if (isSearch && HasText || !isSearch)
{
Expand All @@ -328,8 +326,7 @@ public void DeselectAll()

public void DrawNode(NodeBase node, float itemHeight, int level = 0)
{
bool HasText = node.Header != null &&
node.Header.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;
bool HasText = node.IsNameMatch(_searchText);

char icon = IconManager.FOLDER_ICON;
if (node.Tag is STGenericMesh)
Expand Down Expand Up @@ -818,14 +815,7 @@ private bool SelectNodeRange(NodeBase node, NodeBase selectedNode1, NodeBase sel

private List<NodeBase> GetSearchableNodes(List<NodeBase> nodes)
{
List<NodeBase> nodeList = new List<NodeBase>();
foreach (var node in nodes)
{
bool hasText = node.Header != null && node.Header.IndexOf(_searchText, StringComparison.OrdinalIgnoreCase) >= 0;
if (hasText)
nodeList.Add(node);
}
return nodeList;
return nodes.Where(n => n.IsNameMatch(_searchText)).ToList();
}

private void LoadTextureIcon(NodeBase node)
Expand Down
6 changes: 6 additions & 0 deletions src/Icons/IconManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ public class IconManager
public const char DESELECT_ICON = '\uf850';
public const char SELECT_ICON = '\uf84c';

public const char INFO_ICON = '\uf05a';
public const char WARNING_ICON = '\uf071';

public const char VIDEO_ICON = '\uf03d';
Expand All @@ -103,6 +104,11 @@ public class IconManager
public const char PATH_CONNECT = '\uf337';
public const char PATH_CONNECT_AUTO = '\uf126';

public const char ICON_WII_U = '\uf0a0'; // HDD
public const char ICON_SWITCH = '\uf11b'; // gamepad
public const char ICON_MOD = '\uf0ad'; // wrench
public const char ICON_DOWNLOAD = '\uf019';

public const int ICON_SIZE = 18;

static bool init = false;
Expand Down