/// <summary> /// Add Find It 2 description: asset type, sub-type, size, height /// </summary> public void SetFindIt2Description() { if (assetType == AssetType.Decal) { findIt2Description = Translations.Translate("FIF_SE_ID"); } else if (assetType == AssetType.Network) { findIt2Description = $"{Translations.Translate("FIF_SE_IN")}, "; if (networkType == Asset.NetworkType.TinyRoads) { findIt2Description += Translations.Translate("FIF_NET_TNR"); } else if (networkType == Asset.NetworkType.SmallRoads) { findIt2Description += Translations.Translate("FIF_NET_SMR"); } else if (networkType == Asset.NetworkType.MediumRoads) { findIt2Description += Translations.Translate("FIF_NET_MDR"); } else if (networkType == Asset.NetworkType.LargeRoads) { findIt2Description += Translations.Translate("FIF_NET_LGR"); } else if (networkType == Asset.NetworkType.Highway) { findIt2Description += Translations.Translate("FIF_NET_HGHW"); } else if (networkType == Asset.NetworkType.Path) { findIt2Description += Translations.Translate("FIF_NET_PATH"); } else if (networkType == Asset.NetworkType.Fence) { findIt2Description += Translations.Translate("FIF_NET_WALL"); } else if (networkType == Asset.NetworkType.WaterStructures) { findIt2Description += Translations.Translate("FIF_NET_WAT"); } else if (networkType == Asset.NetworkType.Utility) { findIt2Description += Translations.Translate("FIF_NET_UTI"); } else if (networkType == Asset.NetworkType.Train) { findIt2Description += Translations.Translate("FIF_NET_TRA"); } else if (networkType == Asset.NetworkType.Unsorted) { findIt2Description += Translations.Translate("FIF_PROP_UNS"); } if (UIFilterNetwork.IsNormalRoads(networkType)) { NetInfo info = prefab as NetInfo; if (UIFilterNetwork.IsOneWay(info)) { findIt2Description += ($", {Translations.Translate("FIF_NET_ONE")}"); } if (UIFilterNetwork.HasParking(info)) { findIt2Description += ($", {Translations.Translate("FIF_NET_PAR")}"); } else { findIt2Description += ($", {Translations.Translate("FIF_NET_NOP")}"); } } } else if (assetType == AssetType.Growable || assetType == AssetType.Rico) { if (assetType == AssetType.Rico) { findIt2Description = $"{Translations.Translate("FIF_SE_IR")}, "; } else { findIt2Description = $"{Translations.Translate("FIF_SE_IG")}, "; } if (subService == ItemClass.SubService.ResidentialLow) { findIt2Description += Translations.Translate("FIF_GR_LDR"); } else if (subService == ItemClass.SubService.ResidentialHigh) { findIt2Description += Translations.Translate("FIF_GR_HDR"); } else if (subService == ItemClass.SubService.ResidentialLowEco) { findIt2Description += Translations.Translate("FIF_GR_LDRE"); } else if (subService == ItemClass.SubService.ResidentialHighEco) { findIt2Description += Translations.Translate("FIF_GR_HDRE"); } else if (subService == ItemClass.SubService.CommercialLow) { findIt2Description += Translations.Translate("FIF_GR_LDC"); } else if (subService == ItemClass.SubService.CommercialHigh) { findIt2Description += Translations.Translate("FIF_GR_HDC"); } else if (subService == ItemClass.SubService.CommercialEco) { findIt2Description += Translations.Translate("FIF_GR_CE"); } else if (subService == ItemClass.SubService.CommercialLeisure) { findIt2Description += Translations.Translate("FIF_GR_LC"); } else if (subService == ItemClass.SubService.CommercialTourist) { findIt2Description += Translations.Translate("FIF_GR_TC"); } else if (subService == ItemClass.SubService.IndustrialGeneric) { findIt2Description += Translations.Translate("FIF_GR_GI"); } else if (subService == ItemClass.SubService.IndustrialFarming) { findIt2Description += Translations.Translate("FIF_GR_FAI"); } else if (subService == ItemClass.SubService.IndustrialForestry) { findIt2Description += Translations.Translate("FIF_GR_FOI"); } else if (subService == ItemClass.SubService.IndustrialOil) { findIt2Description += Translations.Translate("FIF_GR_OII"); } else if (subService == ItemClass.SubService.IndustrialOre) { findIt2Description += Translations.Translate("FIF_GR_ORI"); } else if (subService == ItemClass.SubService.OfficeGeneric) { findIt2Description += Translations.Translate("FIF_GR_O"); } else if (subService == ItemClass.SubService.OfficeHightech) { findIt2Description += Translations.Translate("FIF_GR_ITC"); } else { findIt2Description += Translations.Translate("FIF_PROP_UNS"); } findIt2Description += $", {size.x}x{size.y}, {(int)buildingHeight} {Translations.Translate("FIF_EF_MET")} ({(int)(buildingHeight * 3.28084f)} {Translations.Translate("FIF_EF_FEE")})"; } else if (assetType == AssetType.Prop) { findIt2Description = $"{Translations.Translate("FIF_SE_IPR")}, "; if (propType == Asset.PropType.PropsIndustrial) { findIt2Description += Translations.Translate("FIF_PROP_IND"); } else if (propType == Asset.PropType.PropsParks) { findIt2Description += Translations.Translate("FIF_PROP_PAR"); } else if (propType == Asset.PropType.PropsCommon) { findIt2Description += Translations.Translate("FIF_PROP_COM"); } else if (propType == Asset.PropType.PropsResidential) { findIt2Description += Translations.Translate("FIF_PROP_RES"); } else if (propType == Asset.PropType.PropsBillboards) { findIt2Description += Translations.Translate("FIF_PROP_BIL"); } else if (propType == Asset.PropType.PropsSpecialBillboards) { findIt2Description += Translations.Translate("FIF_PROP_SPE"); } else if (propType == Asset.PropType.PropsLights) { findIt2Description += Translations.Translate("FIF_PROP_LIG"); } else if (propType == Asset.PropType.Natural) { findIt2Description += Translations.Translate("FIF_PROP_NAT"); } else if (propType == Asset.PropType.Unsorted) { findIt2Description += Translations.Translate("FIF_PROP_UNS"); } else if (propType == Asset.PropType.PropsMarker) { findIt2Description += Translations.Translate("FIF_PROP_MAR"); } else if (propType == Asset.PropType.PropsUnsortedVehicle) { findIt2Description += Translations.Translate("FIF_PROP_VEH"); } else if (propType == Asset.PropType.PropsTree) { findIt2Description += Translations.Translate("FIF_PROP_TRE"); } else if (propType == Asset.PropType.PropsMoterVehicle) { findIt2Description += Translations.Translate("FIF_PROP_MOT"); } else if (propType == Asset.PropType.PropsRailwayVehicle) { findIt2Description += Translations.Translate("FIF_PROP_RAI"); } else if (propType == Asset.PropType.PropsAircraft) { findIt2Description += Translations.Translate("FIF_PROP_AIR"); } else if (propType == Asset.PropType.PropsWaterCraft) { findIt2Description += Translations.Translate("FIF_PROP_WAT"); } PropInfo propInfo = m_prefab as PropInfo; // terrain conforming? if (propInfo.m_material?.shader == propFenceShader) { findIt2Description += $", {Translations.Translate("FIF_PROP_TC")}"; } else { findIt2Description += $", {Translations.Translate("FIF_PROP_NTC")}"; } } else if (assetType == AssetType.Tree) { findIt2Description = $"{Translations.Translate("FIF_SE_IT")}, "; if (treeType == Asset.TreeType.SmallTree) { findIt2Description += Translations.Translate("FIF_TREE_SM"); } else if (treeType == Asset.TreeType.MediumTree) { findIt2Description += Translations.Translate("FIF_TREE_MD"); } else if (treeType == Asset.TreeType.LargeTree) { findIt2Description += Translations.Translate("FIF_TREE_LG"); } } else if (assetType == AssetType.Ploppable) { findIt2Description = $"{Translations.Translate("FIF_SE_IP")}, "; if (service == ItemClass.Service.Electricity) { findIt2Description += Translations.Translate("FIF_PLOP_E"); } else if (service == ItemClass.Service.Water) { findIt2Description += Translations.Translate("FIF_PLOP_W"); } else if (service == ItemClass.Service.Garbage) { findIt2Description += Translations.Translate("FIF_PLOP_G"); } else if (service == ItemClass.Service.PlayerIndustry) { findIt2Description += Translations.Translate("FIF_PLOP_I"); } else if (service == ItemClass.Service.Fishing) { findIt2Description += Translations.Translate("FIF_PLOP_FI"); } else if (service == ItemClass.Service.HealthCare) { findIt2Description += Translations.Translate("FIF_PLOP_H"); } else if (service == ItemClass.Service.FireDepartment) { findIt2Description += Translations.Translate("FIF_PLOP_F"); } else if (service == ItemClass.Service.Disaster) { findIt2Description += Translations.Translate("FIF_PLOP_D"); } else if (service == ItemClass.Service.PoliceDepartment) { findIt2Description += Translations.Translate("FIF_PLOP_P"); } else if (service == ItemClass.Service.Education) { findIt2Description += Translations.Translate("FIF_PLOP_ED"); } else if (service == ItemClass.Service.PlayerEducation) { findIt2Description += Translations.Translate("FIF_PLOP_C"); } else if (service == ItemClass.Service.Museums) { findIt2Description += Translations.Translate("FIF_PLOP_C"); } else if (service == ItemClass.Service.VarsitySports) { findIt2Description += Translations.Translate("FIF_PLOP_V"); } else if (service == ItemClass.Service.PublicTransport) { findIt2Description += Translations.Translate("FIF_PLOP_PT"); } else if (service == ItemClass.Service.Tourism) { findIt2Description += Translations.Translate("FIF_PLOP_PT"); } else if (service == ItemClass.Service.Beautification) { findIt2Description += Translations.Translate("FIF_PLOP_PPW"); } else if (service == ItemClass.Service.Monument) { findIt2Description += Translations.Translate("FIF_PLOP_U"); } else { findIt2Description += Translations.Translate("FIF_PROP_UNS"); } findIt2Description += $", {size.x}x{size.y}, {(int)buildingHeight} {Translations.Translate("FIF_EF_MET")} ({(int)(buildingHeight * 3.28084f)} {Translations.Translate("FIF_EF_FEE")})"; } findIt2Description += "\n"; }
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); } }
/// <summary> /// Called by the game when the mod options panel is setup. /// </summary> public void OnSettingsUI(UIHelperBase helper) { try { if (FindIt.instance == null) { AssetTagList.instance = new AssetTagList(); } UIHelper group = helper.AddGroup(Name) as UIHelper; UIPanel panel = group.self as UIPanel; // Disable debug messages logging UICheckBox checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DM"), Settings.hideDebugMessages, (b) => { Settings.hideDebugMessages = b; XMLUtils.SaveSettings(); }); checkBox.tooltip = Translations.Translate("FIF_SET_DMTP"); group.AddSpace(10); // Center the main toolbar checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_CMT"), Settings.centerToolbar, (b) => { Settings.centerToolbar = b; XMLUtils.SaveSettings(); if (FindIt.instance != null) { FindIt.instance.UpdateMainToolbar(); } }); checkBox.tooltip = Translations.Translate("FIF_SET_CMTTP"); group.AddSpace(10); // Unlock all checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_UL"), Settings.unlockAll, (b) => { Settings.unlockAll = b; XMLUtils.SaveSettings(); }); checkBox.tooltip = Translations.Translate("FIF_SET_ULTP"); group.AddSpace(10); // Fix bad props next loaded save // Implemented by samsamTS. Need to figure out why this is needed. UICheckBox fixProps = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_BP"), false, (b) => { Settings.fixBadProps = b; XMLUtils.SaveSettings(); }); fixProps.tooltip = Translations.Translate("FIF_SET_BPTP"); group.AddSpace(10); // Use system default browser instead of steam overlay UICheckBox useDefaultBrowser = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DB"), Settings.useDefaultBrowser, (b) => { Settings.useDefaultBrowser = b; XMLUtils.SaveSettings(); }); useDefaultBrowser.tooltip = Translations.Translate("FIF_SET_DBTP"); group.AddSpace(10); // Disable update notice UICheckBox disableUpdateNotice = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DUN"), Settings.disableUpdateNotice, (b) => { Settings.disableUpdateNotice = b; XMLUtils.SaveSettings(); }); useDefaultBrowser.tooltip = Translations.Translate("FIF_SET_DBTP"); group.AddSpace(10); // Disable update notice UICheckBox separateSearchKeyword = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_SSK"), Settings.separateSearchKeyword, (b) => { Settings.separateSearchKeyword = b; XMLUtils.SaveSettings(); }); separateSearchKeyword.tooltip = Translations.Translate("FIF_SET_SSKTP"); group.AddSpace(10); // languate settings UIDropDown languageDropDown = (UIDropDown)group.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) => { Translations.Index = value; XMLUtils.SaveSettings(); }); languageDropDown.width = 300; group.AddSpace(10); // show path to FindItCustomTags.xml string path = Path.Combine(DataLocation.localApplicationData, "FindItCustomTags.xml"); UITextField customTagsFilePath = (UITextField)group.AddTextfield(Translations.Translate("FIF_SET_CTFL"), path, _ => { }, _ => { }); customTagsFilePath.width = panel.width - 30; // from aubergine10's AutoRepair if (Application.platform == RuntimePlatform.WindowsPlayer) { group.AddButton(Translations.Translate("FIF_SET_CTFOP"), () => System.Diagnostics.Process.Start("explorer.exe", "/select," + path)); } // shortcut keys panel.gameObject.AddComponent <MainButtonKeyMapping>(); panel.gameObject.AddComponent <AllKeyMapping>(); panel.gameObject.AddComponent <NetworkKeyMapping>(); panel.gameObject.AddComponent <PloppableKeyMapping>(); panel.gameObject.AddComponent <GrowableKeyMapping>(); panel.gameObject.AddComponent <RicoKeyMapping>(); panel.gameObject.AddComponent <GrwbRicoKeyMapping>(); panel.gameObject.AddComponent <PropKeyMapping>(); panel.gameObject.AddComponent <DecalKeyMapping>(); panel.gameObject.AddComponent <TreeKeyMapping>(); panel.gameObject.AddComponent <RandomSelectionKeyMapping>(); group.AddSpace(10); } catch (Exception e) { Debugging.Message("OnSettingsUI failed"); 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); } }
public void OnSettingsUI(UIHelperBase helper) { try { if (FindIt.instance == null) { AssetTagList.instance = new AssetTagList(); } UIHelper group = helper.AddGroup(Name) as UIHelper; UIPanel panel = group.self as UIPanel; UICheckBox checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_DM"), Debugging.hideDebugMessages.value, (b) => { Debugging.hideDebugMessages.value = b; }); checkBox.tooltip = Translations.Translate("FIF_SET_DMTP"); group.AddSpace(10); checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_CMT"), FindIt.centerToolbar.value, (b) => { FindIt.centerToolbar.value = b; if (FindIt.instance != null) { FindIt.instance.UpdateMainToolbar(); } }); checkBox.tooltip = Translations.Translate("FIF_SET_CMTTP"); checkBox = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_UL"), FindIt.unlockAll.value, (b) => { FindIt.unlockAll.value = b; }); checkBox.tooltip = Translations.Translate("FIF_SET_ULTP"); group.AddSpace(10); UICheckBox fixProps = (UICheckBox)group.AddCheckbox(Translations.Translate("FIF_SET_BP"), false, (b) => { FindIt.fixBadProps = b; }); fixProps.tooltip = Translations.Translate("FIF_SET_BPTP"); group.AddSpace(10); panel.gameObject.AddComponent <OptionsKeymapping>(); group.AddSpace(10); UIDropDown languageDropDown = (UIDropDown)group.AddDropdown(Translations.Translate("TRN_CHOICE"), Translations.LanguageList, Translations.Index, (value) => { Translations.Index = value; }); group.AddSpace(10); } catch (Exception e) { Debugging.Message("OnSettingsUI failed"); Debugging.LogException(e); } }