/// <summary>
        /// Creates a tooltip string for a building, including key stats.
        /// </summary>
        /// <param name="building">Building to generate for</param>
        /// <returns>A tooltip string</returns>
        private string BuildingTooltip(BuildingData building)
        {
            // Safety check.
            if (building?.prefab == null)
            {
                return(String.Empty);
            }

            StringBuilder tooltip = new StringBuilder();

            tooltip.AppendLine(building.DisplayName);

            // Construction cost.
            try
            {
                tooltip.AppendLine(LocaleFormatter.FormatCost(building.prefab.GetConstructionCost(), false));
            }
            catch
            {
                // Don't care - just don't show construction cost in the tooltip.
            }

            // Only add households or workplaces for Private AI types, not for e.g. Beautification (dummy service).
            if (building.prefab.GetAI() is PrivateBuildingAI thisAI)
            {
                // Household or workplace count.
                if (building.prefab.GetService() == ItemClass.Service.Residential)
                {
                    // Residential - households.
                    tooltip.Append(Translations.Translate("PRR_HOU"));
                    tooltip.Append(": ");
                    tooltip.AppendLine(thisAI.CalculateHomeCount(building.prefab.GetClassLevel(), new Randomizer(), building.prefab.GetWidth(), building.prefab.GetLength()).ToString());
                }
                else
                {
                    // Non-residential - workplaces.
                    int[] workplaces = new int[4];

                    tooltip.Append(Translations.Translate("PRR_WOR"));
                    tooltip.Append(": ");
                    thisAI.CalculateWorkplaceCount(building.prefab.GetClassLevel(), new Randomizer(), building.prefab.GetWidth(), building.prefab.GetLength(), out workplaces[0], out workplaces[1], out workplaces[2], out workplaces[3]);
                    tooltip.AppendLine(workplaces.Sum().ToString());
                }
            }

            // Physical size.
            tooltip.Append("Size: ");
            tooltip.Append(building.prefab.GetWidth());
            tooltip.Append("x");
            tooltip.AppendLine(building.prefab.GetLength().ToString());

            return(tooltip.ToString());
        }
Exemplo n.º 2
0
        public static string GetLocalizedTooltip(Asset asset, PrefabInfo prefab, string title)
        {
            MilestoneInfo unlockMilestone = prefab.GetUnlockMilestone();

            string text = TooltipHelper.Format(new string[]
            {
                LocaleFormatter.Title,
                title,
                LocaleFormatter.Sprite,
                (!string.IsNullOrEmpty(prefab.m_InfoTooltipThumbnail)) ? prefab.m_InfoTooltipThumbnail : prefab.name,
                LocaleFormatter.Text,
                (asset.findIt2Description + Asset.GetLocalizedDescription(prefab)),
                LocaleFormatter.Locked,
                (!ToolsModifierControl.IsUnlocked(unlockMilestone)).ToString()
            });

            ToolsModifierControl.GetUnlockingInfo(unlockMilestone, out string unlockDesc, out string currentValue, out string targetValue, out string progress, out string locked);

            string addTooltip = TooltipHelper.Format(new string[]
            {
                LocaleFormatter.LockedInfo,
                locked,
                LocaleFormatter.UnlockDesc,
                unlockDesc,
                LocaleFormatter.UnlockPopulationProgressText,
                progress,
                LocaleFormatter.UnlockPopulationTarget,
                targetValue,
                LocaleFormatter.UnlockPopulationCurrent,
                currentValue
            });

            text = TooltipHelper.Append(text, addTooltip);
            PrefabAI aI = prefab.GetAI();

            if (aI != null)
            {
                text = TooltipHelper.Append(text, aI.GetLocalizedTooltip());
            }

            if (prefab is PropInfo || prefab is TreeInfo)
            {
                text = TooltipHelper.Append(text, TooltipHelper.Format(new string[]
                {
                    LocaleFormatter.Cost,
                    LocaleFormatter.FormatCost(prefab.GetConstructionCost(), false)
                }));
            }

            return(text);
        }
 public override string GetLocalizedTooltip()
 {
     return(TooltipHelper.Format(new string[]
     {
         LocaleFormatter.Cost,
         LocaleFormatter.FormatCost(this.GetConstructionCost(), true),
         LocaleFormatter.Upkeep,
         LocaleFormatter.FormatUpkeep(this.GetMaintenanceCost(), true),
         LocaleFormatter.Speed,
         LocaleFormatter.FormatGeneric("AIINFO_SPEED", new object[]
         {
             15f
         })
     }));
 }