Esempio n. 1
0
        private void calculateBaseSizes()
        {
            // compute the max size of a digit and separators in the English font, for the timer part.
            PixelFont     font          = Dialog.Languages["english"].Font;
            float         fontFaceSize  = Dialog.Languages["english"].FontFaceSize;
            PixelFontSize pixelFontSize = font.Get(fontFaceSize);

            for (int i = 0; i < 10; i++)
            {
                float digitWidth = pixelFontSize.Measure(i.ToString()).X;
                if (digitWidth > numberWidth)
                {
                    numberWidth = digitWidth;
                }
            }
            spacerWidth  = pixelFontSize.Measure('.').X;
            numberHeight = pixelFontSize.Measure("0:.").Y;

            // measure the ranks in the font for the current language.
            rankMeasurements = new Dictionary <string, Vector2>()
            {
                { "Gold", ActiveFont.Measure(Dialog.Clean("collabutils2_speedberry_gold") + " ") * targetTimeScale },
                { "Silver", ActiveFont.Measure(Dialog.Clean("collabutils2_speedberry_silver") + " ") * targetTimeScale },
                { "Bronze", ActiveFont.Measure(Dialog.Clean("collabutils2_speedberry_bronze") + " ") * targetTimeScale }
            };
        }
Esempio n. 2
0
        private static void DrawTime(Vector2 position, string timeString, float scale = 1f, bool valid = true,
                                     bool finished = false, bool bestTime = false, float alpha = 1f)
        {
            float         numberWidth   = 0f;
            float         spacerWidth   = 0f;
            PixelFontSize pixelFontSize =
                Dialog.Languages["english"].Font.Get(Dialog.Languages["english"].FontFaceSize);

            for (int index = 0; index < 10; ++index)
            {
                float x1 = pixelFontSize.Measure(index.ToString()).X;
                if ((double)x1 > numberWidth)
                {
                    numberWidth = x1;
                }
            }

            spacerWidth = pixelFontSize.Measure('.').X;

            PixelFont font         = Dialog.Languages["english"].Font;
            float     fontFaceSize = Dialog.Languages["english"].FontFaceSize;
            float     num1         = scale;
            float     x            = position.X;
            float     y            = position.Y;
            Color     color1       = Color.White * alpha;
            Color     color2       = Color.LightGray * alpha;

            if (!valid)
            {
                color1 = Calc.HexToColor("918988") * alpha;
                color2 = Calc.HexToColor("7a6f6d") * alpha;
            }
            else if (bestTime)
            {
                color1 = Calc.HexToColor("fad768") * alpha;
                color2 = Calc.HexToColor("cfa727") * alpha;
            }
            else if (finished)
            {
                color1 = Calc.HexToColor("6ded87") * alpha;
                color2 = Calc.HexToColor("43d14c") * alpha;
            }

            for (int index = 0; index < timeString.Length; ++index)
            {
                char ch = timeString[index];

                Color color3 = ch == ':' || ch == '.' || (double)num1 < (double)scale ? color2 : color1;

                float num2 = (float)((ch == ':' || ch == '.' ? spacerWidth : numberWidth) + 4.0) * num1;
                font.DrawOutline(fontFaceSize, ch.ToString(), new Vector2(x + num2 / 2f, y), new Vector2(0.5f, 1f),
                                 Vector2.One * num1, color3, 2f, Color.Black);
                x += num2;
            }
        }
Esempio n. 3
0
        public static void CalculateBaseSizes()
        {
            PixelFont     font          = Dialog.Languages["english"].Font;
            float         fontFaceSize  = Dialog.Languages["english"].FontFaceSize;
            PixelFontSize pixelFontSize = font.Get(fontFaceSize);

            for (int i = 0; i < 10; i++)
            {
                float x = pixelFontSize.Measure(i.ToString()).X;
                if (x > numberWidth)
                {
                    numberWidth = x;
                }
            }
            spacerWidth = pixelFontSize.Measure('.').X;
        }
Esempio n. 4
0
        private void CalculateBaseSizes()
        {
            // compute the max size of a digit and separators in the English font, for the timer part.
            PixelFont     font          = Dialog.Languages["english"].Font;
            float         fontFaceSize  = Dialog.Languages["english"].FontFaceSize;
            PixelFontSize pixelFontSize = font.Get(fontFaceSize);

            for (int i = 0; i < 10; i++)
            {
                float digitWidth = pixelFontSize.Measure(i.ToString()).X;
                if (digitWidth > numberWidth)
                {
                    numberWidth = digitWidth;
                }
            }
            spacerWidth = pixelFontSize.Measure('.').X;
        }