private static void Init(UIComponent component, bool b) { component.eventVisibilityChanged -= new PropertyChangedEventHandler <bool>(Init); try { if (component.objectUserData is PrefabInfo prefab) { string name = Asset.GetName(prefab); if (AssetTagList.instance.assets.ContainsKey(name)) { ImageUtils.FixThumbnails(prefab, component as UIButton); Asset asset = AssetTagList.instance.assets[name]; component.eventVisibilityChanged += (c, p) => { if (Settings.unlockAll) { c.isEnabled = true; } else { c.isEnabled = ToolsModifierControl.IsUnlocked(prefab.GetUnlockMilestone()); } }; // Fixing focused texture component.eventClicked += new MouseEventHandler(FixFocusedTexture); // Adding custom tag icon UISprite tagSprite = component.AddUIComponent <UISprite>(); tagSprite.size = new Vector2(20, 16); tagSprite.atlas = FindIt.atlas; tagSprite.spriteName = "Tag"; tagSprite.opacity = 0.5f; tagSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; tagSprite.relativePosition = new Vector3(component.width - tagSprite.width - 5, 5); tagSprite.isVisible = false; if (CustomTagsLibrary.assetTags.ContainsKey(name)) { tagSprite.tooltip = CustomTagsLibrary.assetTags[name]; } else { tagSprite.tooltip = null; } tagSprite.eventMouseEnter += (c, p) => { tagSprite.opacity = 1f; }; tagSprite.eventMouseLeave += (c, p) => { tagSprite.opacity = 0.5f; }; tagSprite.eventClick += (c, p) => { p.Use(); UITagsWindow.ShowAt(asset, tagSprite); }; component.eventMouseEnter += (c, p) => { tagSprite.isVisible = true; }; component.eventMouseLeave += (c, p) => { if (asset.tagsCustom.Count == 0) { tagSprite.isVisible = false; } }; // adding DLC/steam icon UISprite m_dlcSprite = component.AddUIComponent <UISprite>(); m_dlcSprite.size = new Vector2(16, 16); m_dlcSprite.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); m_dlcSprite.opacity = 0.8f; m_dlcSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; m_dlcSprite.relativePosition = new Vector3(component.width - m_dlcSprite.width - 3, component.height - m_dlcSprite.height - 3); m_dlcSprite.isVisible = false; m_dlcSprite.eventMouseLeave += (c, p) => { m_dlcSprite.tooltipBox.Hide(); }; m_dlcSprite.tooltip = null; m_dlcSprite.isVisible = false; if (asset != null) { if (FindIt.isNext2Enabled && AssetTagList.instance.next2Assets.Contains(asset)) { m_dlcSprite.isVisible = true; m_dlcSprite.spriteName = "UIFilterWorkshopItemsFocusedHovered"; m_dlcSprite.tooltip = "Network Extension 2 Mod"; } else if (FindIt.isETSTEnabled && AssetTagList.instance.etstAssets.Contains(asset)) { m_dlcSprite.isVisible = true; m_dlcSprite.spriteName = "UIFilterWorkshopItemsFocusedHovered"; m_dlcSprite.tooltip = "Extra Train Station Tracks Mod"; } else if (FindIt.isOWTTEnabled && AssetTagList.instance.owttAssets.Contains(asset)) { m_dlcSprite.isVisible = true; m_dlcSprite.spriteName = "UIFilterWorkshopItemsFocusedHovered"; m_dlcSprite.tooltip = "One-Way Train Tracks Mod"; } else if (!asset.prefab.m_isCustomContent) { SetDLCSprite(m_dlcSprite, asset.prefab.m_dlcRequired); } else { if (!asset.author.IsNullOrWhiteSpace() && (asset.steamID != 0)) { m_dlcSprite.opacity = 0.2f; m_dlcSprite.isVisible = true; m_dlcSprite.spriteName = "UIFilterWorkshopItems"; m_dlcSprite.tooltip = "By " + asset.author + "\n" + Translations.Translate("FIF_UIS_WS"); } } } if (PlatformService.IsOverlayEnabled() && m_dlcSprite.spriteName == "UIFilterWorkshopItems") { m_dlcSprite.eventMouseUp += (c, p) => { if (!p.used && p.buttons == UIMouseButton.Right) { PublishedFileId publishedFileId = new PublishedFileId(asset.steamID); if (publishedFileId != PublishedFileId.invalid) { if (!Settings.useDefaultBrowser) { PlatformService.ActivateGameOverlayToWorkshopItem(publishedFileId); } else { System.Diagnostics.Process.Start("https://steamcommunity.com/sharedfiles/filedetails/?id=" + publishedFileId); } p.Use(); } } }; } } } } catch (Exception e) { Debugging.LogException(e); } }
private static void Init(UIComponent component, bool b) { component.eventVisibilityChanged -= new PropertyChangedEventHandler <bool>(Init); try { if (component.objectUserData is PrefabInfo prefab) { string name = Asset.GetName(prefab); if (AssetTagList.instance.assets.ContainsKey(name)) { ImageUtils.FixThumbnails(prefab, component as UIButton); Asset asset = AssetTagList.instance.assets[name]; component.eventVisibilityChanged += (c, p) => { if (Settings.unlockAll) { c.isEnabled = true; } else { c.isEnabled = ToolsModifierControl.IsUnlocked(prefab.GetUnlockMilestone()); } }; // Fixing focused texture component.eventClicked += new MouseEventHandler(FixFocusedTexture); // Adding custom tag icon UISprite tagSprite = component.AddUIComponent <UISprite>(); tagSprite.size = new Vector2(20, 16); tagSprite.atlas = FindIt.atlas; tagSprite.spriteName = "Tag"; tagSprite.opacity = 0.5f; tagSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; tagSprite.relativePosition = new Vector3(component.width - tagSprite.width - 5, 5); tagSprite.isVisible = false; if (CustomTagsLibrary.assetTags.ContainsKey(name)) { tagSprite.tooltip = CustomTagsLibrary.assetTags[name]; } else { tagSprite.tooltip = null; } tagSprite.eventMouseEnter += (c, p) => { tagSprite.opacity = 1f; }; tagSprite.eventMouseLeave += (c, p) => { tagSprite.opacity = 0.5f; }; tagSprite.eventClick += (c, p) => { p.Use(); UITagsWindow.ShowAt(asset, tagSprite); }; component.eventMouseEnter += (c, p) => { tagSprite.isVisible = true; }; component.eventMouseLeave += (c, p) => { if (asset.tagsCustom.Count == 0) { tagSprite.isVisible = false; } }; // Adding steam icon if (asset.steamID != 0) { UISprite steamSprite = component.AddUIComponent <UISprite>(); steamSprite.size = new Vector2(26, 16); steamSprite.atlas = SamsamTS.UIUtils.GetAtlas("Ingame"); steamSprite.spriteName = "SteamWorkshop"; steamSprite.opacity = 0.05f; steamSprite.tooltipBox = UIView.GetAView().defaultTooltipBox; steamSprite.relativePosition = new Vector3(component.width - steamSprite.width - 5, component.height - steamSprite.height - 5); if (!asset.author.IsNullOrWhiteSpace()) { steamSprite.tooltip = "By " + asset.author + "\n" + Translations.Translate("FIF_UIS_WS"); } if (PlatformService.IsOverlayEnabled()) { steamSprite.eventMouseUp += (c, p) => { if (!p.used && p.buttons == UIMouseButton.Right) { PublishedFileId publishedFileId = new PublishedFileId(asset.steamID); if (publishedFileId != PublishedFileId.invalid) { PlatformService.ActivateGameOverlayToWorkshopItem(publishedFileId); p.Use(); } } }; } } } } } catch (Exception e) { Debugging.LogException(e); } }