Esempio n. 1
0
            /// <summary>Turns data into a CuiTextComponent.</summary>
            /// <param name="data">The data to base the CuiTextComponent on.</param>
            /// <returns>A CuiTextComponent based on the data.</returns>
            public static CuiTextComponent ToTextComponent(Dictionary <string, object> data)
            {
                CuiTextComponent textComponent = new CuiTextComponent();

                if (data.ContainsKey(TextProperties.align))
                {
                    textComponent.Align = EnumPlus.ToEnum <TextAnchor>(data[TextProperties.align].ToString());
                }
                if (data.ContainsKey(TextProperties.color))
                {
                    textComponent.Color = data[TextProperties.color].ToString();
                }
                if (data.ContainsKey(TextProperties.font))
                {
                    textComponent.Font = data[TextProperties.font].ToString();
                }
                if (data.ContainsKey(TextProperties.fontSize))
                {
                    int fontSize = textComponent.FontSize;
                    if (!int.TryParse(data[TextProperties.fontSize].ToString(), out fontSize))
                    {
                        instance.PrintWarning("Could not succesfully parse " + data[TextProperties.fontSize].ToString() + ", a value retrieved from the configuration file, as a font size. Returned a default value of " + fontSize + " instead.");
                    }
                    textComponent.FontSize = fontSize;
                }
                if (data.ContainsKey(TextProperties.text))
                {
                    textComponent.Text = data[TextProperties.text].ToString();
                }

                return(textComponent);
            }
Esempio n. 2
0
        /// <summary>Reinitializes the static Ui.</summary>
        /// <param name="key">The key of the icon (equal to the panel it belongs to).</param>
        /// <param name="value">The value of the icon.</param>
        private void IconLoaded(string key, string value)
        {
            PanelTypes type = EnumPlus.ToEnum <PanelTypes>(key);

            for (int i = 0; i < BasePlayer.activePlayerList.Count; i++)
            {
                CuiHelper.DestroyUi(BasePlayer.activePlayerList[i], UniqueElementName(ContainerTypes.Static, ContainerParent, type.ToString()));
            }

            staticContainers[(int)type] = GetStaticContainer(type);

            for (int j = 0; j < BasePlayer.activePlayerList.Count; j++)
            {
                if (!BasePlayer.activePlayerList[j].IsDead())
                {
                    CuiHelper.AddUi(BasePlayer.activePlayerList[j], staticContainers[(int)type]);
                    UpdateField(BasePlayer.activePlayerList[j], type);
                }
            }
        }