Пример #1
0
        /// <summary>
        /// Generates an English-formatted string indicating an amount of money.
        /// </summary>
        /// <param name="money"></param>
        /// <param name="addDenom"></param>
        /// <param name="addColors"></param>
        /// <param name="addColorPulse">Adds Terraria's standard text pulsing to rendered colors.</param>
        /// <returns></returns>
        public static string[] RenderMoneyDenominations(long money, bool addDenom, bool addColors, bool addColorPulse = false)
        {
            float colorPulse = addColorPulse
                                ? ((float)Main.mouseTextColor / 255f)
                                : 1f;

            return(ItemMoneyLibraries.RenderMoneyDenominations(money, addDenom, addColors, Color.White * colorPulse));
        }
Пример #2
0
        /// <summary>
        /// Generates an English-formatted string indicating an amount of money.
        /// </summary>
        /// <param name="money"></param>
        /// <param name="addDenom"></param>
        /// <param name="addColors"></param>
        /// <param name="tint"></param>
        /// <returns></returns>
        public static string[] RenderMoneyDenominations(long money, bool addDenom, bool addColors, Color tint)
        {
            var denoms   = ItemMoneyLibraries.GetMoneyDenominations(money);
            var rendered = new List <string>(4);

            if (denoms.platinum != 0)
            {
                string render = denoms.platinum.ToString();
                if (addDenom)
                {
                    render += " " + Language.GetTextValue("Currency.Platinum");                          //Lang.inter[15];
                }
                if (addColors)
                {
                    Color  color    = XNAColorLibraries.Mul(ItemMoneyLibraries.PlatinumCoinColor, tint);
                    string colorHex = MiscLibraries.RenderColorHex(color);
                    render = "[c/" + colorHex + ":" + render + "]";
                }
                rendered.Add(render);
            }
            if (denoms.gold != 0)
            {
                string render = denoms.gold.ToString();
                if (addDenom)
                {
                    render += " " + Language.GetTextValue("Currency.Gold");                          //Lang.inter[16];
                }
                if (addColors)
                {
                    Color  color    = XNAColorLibraries.Mul(ItemMoneyLibraries.GoldCoinColor, tint);
                    string colorHex = MiscLibraries.RenderColorHex(color);
                    render = "[c/" + colorHex + ":" + render + "]";
                }
                rendered.Add(render);
            }
            if (denoms.silver != 0)
            {
                string render = denoms.silver.ToString();
                if (addDenom)
                {
                    render += " " + Language.GetTextValue("Currency.Silver");                          //Lang.inter[17];
                }
                if (addColors)
                {
                    Color  color    = XNAColorLibraries.Mul(ItemMoneyLibraries.SilverCoinColor, tint);
                    string colorHex = MiscLibraries.RenderColorHex(color);
                    render = "[c/" + colorHex + ":" + render + "]";
                }
                rendered.Add(render);
            }
            if (denoms.copper != 0)
            {
                string render = denoms.copper.ToString();
                if (addDenom)
                {
                    render += " " + Language.GetTextValue("Currency.Copper");                          //Lang.inter[18];
                }
                if (addColors)
                {
                    Color  color    = XNAColorLibraries.Mul(ItemMoneyLibraries.CopperCoinColor, tint);
                    string colorHex = MiscLibraries.RenderColorHex(color);
                    render = "[c/" + colorHex + ":" + render + "]";
                }
                rendered.Add(render);
            }

            return(rendered.ToArray());
        }