public void Search() { PrefabInfo current = null; UIScrollPanelItem.ItemData selected = null; if (scrollPanel.selectedItem != null) { current = scrollPanel.selectedItem.asset.prefab; } string text = ""; Asset.AssetType type = Asset.AssetType.All; if (input != null) { text = input.text; type = (Asset.AssetType)typeFilter.selectedIndex; if (!FindIt.isRicoEnabled && type >= Asset.AssetType.Rico) { type++; } } List <Asset> matches = AssetTagList.instance.Find(text, type); scrollPanel.Clear(); foreach (Asset asset in matches) { if (asset.prefab != null) { UIScrollPanelItem.ItemData data = new UIScrollPanelItem.ItemData(); data.name = asset.title; data.tooltip = Asset.GetLocalizedTooltip(asset.prefab, data.name); data.tooltipBox = GeneratedPanel.GetTooltipBox(TooltipHelper.GetHashCode(data.tooltip)); data.asset = asset; scrollPanel.itemsData.Add(data); if (asset.prefab == current) { selected = data; } } } scrollPanel.DisplayAt(0); scrollPanel.selectedItem = selected; if (scrollPanel.selectedItem != null) { FindIt.SelectPrefab(scrollPanel.selectedItem.asset.prefab); } else { ToolsModifierControl.SetTool <DefaultTool>(); } }
public void Search() { PrefabInfo current = null; UIScrollPanelItem.ItemData selected = null; if (scrollPanel.selectedItem != null) { current = scrollPanel.selectedItem.asset.prefab; } string text = ""; DropDownOptions type = DropDownOptions.All; if (input != null) { text = input.text; type = (DropDownOptions)typeFilter.selectedIndex; if (!FindIt.isRicoEnabled && type >= DropDownOptions.Rico) { type += 2; } } // set up prop categories for props generated by Elektrix's TVP mod. Need the TVP Patch mod if (FindIt.isTVPPatchEnabled && !AssetTagList.instance.isTVPPatchModProcessed) { AssetTagList.instance.SetTVPProps(); } // extra size check for growable if (type == DropDownOptions.Growable) { // if switch back from rico with size > 4, default size = all if (UISearchBox.instance.buildingSizeFilterIndex.x > 4) { UISearchBox.instance.sizeFilterX.selectedIndex = 0; } if (UISearchBox.instance.buildingSizeFilterIndex.y > 4) { UISearchBox.instance.sizeFilterY.selectedIndex = 0; } } matches = AssetTagList.instance.Find(text, type); // sort by used/unused instance count if (Settings.showInstancesCounter && Settings.instanceCounterSort != 0) { if (Settings.instanceCounterSort == 1) { if (Settings.includePOinstances) { matches = matches.OrderByDescending(s => (s.instanceCount + s.poInstanceCount)).ToList(); } else { matches = matches.OrderByDescending(s => s.instanceCount).ToList(); } } else { if (Settings.includePOinstances) { matches = matches.OrderBy(s => (s.instanceCount + s.poInstanceCount)).ToList(); } else { matches = matches.OrderBy(s => s.instanceCount).ToList(); } } } // sort by most recently downloaded else if (!Settings.useRelevanceSort) { matches = matches.OrderByDescending(s => s.downloadTime).ToList(); } // sort by relevance, same as original Find It else { // sort network by ui priority instead if (UISearchBox.instance?.typeFilter.selectedIndex == 1) { matches = matches.OrderBy(s => s.uiPriority).ToList(); } else { text = text.ToLower().Trim(); // if search input box is not empty, sort by score if (!text.IsNullOrWhiteSpace()) { float maxScore = 0; foreach (Asset assetItr in matches) { if (assetItr.score > 0) { maxScore = assetItr.score; break; } } if (maxScore > 0) { matches = matches.OrderByDescending(s => s.score).ToList(); } else { matches = matches.OrderBy(s => s.title).ToList(); } } // if seach input box is empty, sort by asset title else { matches = matches.OrderBy(s => s.title).ToList(); } } } scrollPanel.Clear(); searchResultList.Clear(); foreach (Asset asset in matches) { if (asset.prefab != null) { UIScrollPanelItem.ItemData data = new UIScrollPanelItem.ItemData(); data.name = asset.title;// + "_" + asset.steamID; data.tooltip = Asset.GetLocalizedTooltip(asset, asset.prefab, data.name); data.tooltipBox = GeneratedPanel.GetTooltipBox(TooltipHelper.GetHashCode(data.tooltip)); data.asset = asset; scrollPanel.itemsData.Add(data); searchResultList.Add(data.name); if (asset.prefab == current) { selected = data; } } } scrollPanel.DisplayAt(0); scrollPanel.selectedItem = selected; if (scrollPanel.selectedItem != null) { FindIt.SelectPrefab(scrollPanel.selectedItem.asset.prefab); } else { ToolsModifierControl.SetTool <DefaultTool>(); } }