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 static void NotifyDownload(PrefabInfo prefab) { Profiler.Info("Notify user of new prefab: {0}", prefab.name); var list = UIView.GetAView().GetComponentsInChildren <ChirpPanel>(); if (list.Count() > 0) { var panel = list[0]; panel.AddMessage(new ChirperMessage(prefab)); var msgsPanel = panel.GetFieldValue <UIScrollablePanel>("m_Container"); var msgPanel = msgsPanel.components[msgsPanel.components.Count() - 1]; var msgButton = (UILabel)msgPanel.components[1]; msgButton.clipChildren = false; var button = msgButton.AddUIComponent <UIButton>(); button.height = 75; button.width = 75; button.relativePosition = new Vector3(5, 20); button.objectUserData = prefab; button.atlas = prefab.m_Atlas; button.normalFgSprite = prefab.m_Thumbnail; button.focusedFgSprite = prefab.m_Thumbnail + "Focused"; button.hoveredFgSprite = prefab.m_Thumbnail + "Hovered"; button.pressedFgSprite = prefab.m_Thumbnail + "Pressed"; button.disabledFgSprite = prefab.m_Thumbnail + "Disabled"; if (prefab.m_Thumbnail == null || prefab.m_Thumbnail == "") { button.normalFgSprite = "ToolbarIconProps"; } string localizedTooltip = prefab.GetLocalizedTooltip(); int hashCode = TooltipHelper.GetHashCode(localizedTooltip); UIComponent tooltipBox = GeneratedPanel.GetTooltipBox(hashCode); button.tooltip = localizedTooltip; button.tooltipBox = tooltipBox; button.eventClick += PrefabButtonClicked; } }
private static bool DrawBuildingButtonOnPanel(BuildingInfo prefab, UIScrollablePanel panel) { int _UIBaseHeight = 109; var BuildingButton = panel.AddUIComponent <UIButton>(); BuildingButton.size = new Vector2(_UIBaseHeight, 100); //apply settings to building buttons. BuildingButton.atlas = prefab.m_Atlas; BuildingButton.normalFgSprite = prefab.m_Thumbnail; BuildingButton.focusedFgSprite = prefab.m_Thumbnail + "Focused"; BuildingButton.hoveredFgSprite = prefab.m_Thumbnail + "Hovered"; BuildingButton.pressedFgSprite = prefab.m_Thumbnail + "Pressed"; BuildingButton.disabledFgSprite = prefab.m_Thumbnail + "Disabled"; if (prefab.m_Thumbnail == null || prefab.m_Thumbnail == "") { BuildingButton.normalFgSprite = "ToolbarIconProps"; } BuildingButton.objectUserData = prefab; BuildingButton.horizontalAlignment = UIHorizontalAlignment.Center; BuildingButton.verticalAlignment = UIVerticalAlignment.Middle; BuildingButton.pivot = UIPivotPoint.TopCenter; //if ( Category == "education" ) // BuildingButton.verticalAlignment = UIVerticalAlignment.Bottom; string localizedTooltip = prefab.GetLocalizedTooltip(); int hashCode = TooltipHelper.GetHashCode(localizedTooltip); UIComponent tooltipBox = GeneratedPanel.GetTooltipBox(hashCode); BuildingButton.tooltipAnchor = UITooltipAnchor.Anchored; BuildingButton.isEnabled = true; BuildingButton.tooltip = localizedTooltip; BuildingButton.tooltipBox = tooltipBox; BuildingButton.eventClick += UI.PrefabButtonClicked; return(true); }
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>(); } }
void DrawBuildingButton(BuildingInfo BuildingPrefab, string type) { try { BuildingButton = new UIButton(); //draw button on appropriate panel. if (type == "reslow") { BuildingButton = BuildingPanels[0].AddUIComponent <UIButton>(); } if (type == "reshigh") { BuildingButton = BuildingPanels[1].AddUIComponent <UIButton>(); } if (type == "comlow") { BuildingButton = BuildingPanels[2].AddUIComponent <UIButton>(); } if (type == "comhigh") { BuildingButton = BuildingPanels[3].AddUIComponent <UIButton>(); } if (type == "office") { BuildingButton = BuildingPanels[4].AddUIComponent <UIButton>(); } if (type == "industrial") { BuildingButton = BuildingPanels[5].AddUIComponent <UIButton>(); } if (type == "farming") { BuildingButton = BuildingPanels[6].AddUIComponent <UIButton>(); } if (type == "oil") { BuildingButton = BuildingPanels[8].AddUIComponent <UIButton>(); } if (type == "forest") { BuildingButton = BuildingPanels[7].AddUIComponent <UIButton>(); } if (type == "ore") { BuildingButton = BuildingPanels[9].AddUIComponent <UIButton>(); } if (type == "leisure") { if (Util.isADinstalled()) { BuildingButton = BuildingPanels[10].AddUIComponent <UIButton>(); } else { BuildingButton = BuildingPanels[3].AddUIComponent <UIButton>(); } } if (type == "tourist") { if (Util.isADinstalled()) { BuildingButton = BuildingPanels[11].AddUIComponent <UIButton>(); } else { BuildingButton = BuildingPanels[3].AddUIComponent <UIButton>(); } } BuildingButton.size = new Vector2(109, 100); //apply settings to building buttons. BuildingButton.atlas = BuildingPrefab.m_Atlas; if (BuildingPrefab.m_Thumbnail == null || BuildingPrefab.m_Thumbnail == "") { BuildingButton.normalFgSprite = "ToolbarIconProps"; } else { BuildingButton.normalFgSprite = BuildingPrefab.m_Thumbnail; BuildingButton.focusedFgSprite = BuildingPrefab.m_Thumbnail + "Focused"; BuildingButton.hoveredFgSprite = BuildingPrefab.m_Thumbnail + "Hovered"; BuildingButton.pressedFgSprite = BuildingPrefab.m_Thumbnail + "Pressed"; BuildingButton.disabledFgSprite = BuildingPrefab.m_Thumbnail + "Disabled"; } BuildingButton.objectUserData = BuildingPrefab; BuildingButton.horizontalAlignment = UIHorizontalAlignment.Center; BuildingButton.verticalAlignment = UIVerticalAlignment.Middle; BuildingButton.pivot = UIPivotPoint.TopCenter; string localizedTooltip = BuildingPrefab.GetLocalizedTooltip(); int hashCode = TooltipHelper.GetHashCode(localizedTooltip); UIComponent tooltipBox = GeneratedPanel.GetTooltipBox(hashCode); BuildingButton.tooltipAnchor = UITooltipAnchor.Anchored; BuildingButton.isEnabled = enabled; BuildingButton.tooltip = localizedTooltip; BuildingButton.tooltipBox = tooltipBox; BuildingButton.eventClick += (sender, e) => BuildingBClicked(sender, e, BuildingPrefab); BuildingButton.eventMouseHover += (sender, e) => BuildingBHovered(sender, e, BuildingPrefab); } catch (Exception e) { Debug.LogException(e); } }