コード例 #1
0
 /// <summary>
 /// Retrieves a pooled label used for displaying stored objects.
 /// </summary>
 /// <param name="parent">The parent panel to add new labels.</param>
 /// <param name="id">The name of the label to be added or created.</param>
 /// <returns>A label which can be used to display stored items, pooled if possible.</returns>
 private CachedStorageLabel GetStorageLabel(GameObject parent, string id)
 {
     if (labelCache.TryGetValue(id, out CachedStorageLabel result))
     {
         result.Reset();
     }
     else
     {
         result         = new CachedStorageLabel(sis, parent, id);
         labelCache[id] = result;
     }
     result.SetActive(true);
     return(result);
 }
コード例 #2
0
        /// <summary>
        /// Updates the text to be displayed for a single stored item.
        /// </summary>
        /// <param name="label">The label to be updated.</param>
        /// <param name="item">The item to be displayed.</param>
        /// <param name="freeze">true to freeze the labels, or false to leave as pending.</param>
        /// <param name="pe">The item's primary element, or null if it has none.</param>
        private void SetItemDescription(CachedStorageLabel label, GameObject item, bool freeze,
                                        PrimaryElement pe)
        {
            var defaultStyle = PluginAssets.Instance.defaultTextStyleSetting;
            var text         = CACHED_BUILDER;
            var rottable     = item.GetSMI <Rottable.Instance>();
            var tooltip      = label.tooltip;
            int lines        = 1;

            text.Clear();
            tooltip.ClearMultiStringTooltip();
            if (item.TryGetComponent(out HighEnergyParticleStorage hepStorage))
            {
                // Radbolts
                text.Append(STRINGS.ITEMS.RADIATION.HIGHENERGYPARITCLE.NAME).Append(": ").
                Append(GameUtil.GetFormattedHighEnergyParticles(hepStorage.Particles));
            }
            else if (pe != null)
            {
                // Element
                var properName = item.GetProperName();
                if (item.TryGetComponent(out KPrefabID id) && Assets.IsTagCountable(id.
                                                                                    PrefabTag))
                {
                    FormatStringPatches.GetUnitFormattedName(text, properName, pe.Units);
                }
                else
                {
                    text.Append(properName);
                }
                text.Append(": ");
                FormatStringPatches.GetFormattedMass(text, pe.Mass);
                if (optimizedStorageTemp != null)
                {
                    text.Append(optimizedStorageTemp);
                    FormatStringPatches.GetFormattedTemperature(text, pe.Temperature);
                }
                else
                {
                    string mass = text.ToString();
                    text.Clear().Append(DETAILTABS.DETAILS.CONTENTS_TEMPERATURE).Replace("{1}",
                                                                                         GameUtil.GetFormattedTemperature(pe.Temperature)).Replace("{0}", mass);
                }
            }