示例#1
0
        protected void CalcTextPosition(out int x, out int y, Boku.Common.BitmapFont font, string label, int line, int lines)
        {
            int widthLabel = font.MeasureString(label);

            if ((this.alignment & Alignment.Left) != 0)
            {
                x = font.LineHeight; // some spacing
            }
            else if ((this.alignment & Alignment.Right) != 0)
            {
                x = BokuGame.width - widthLabel - font.LineHeight; // some spacing
            }
            else
            {
                x = (BokuGame.width - widthLabel) / 2;
            }
            if ((this.alignment & Alignment.Top) != 0)
            {
                y = font.LineHeight * line + font.LineHeight / 2; // some spacing
            }
            else if ((this.alignment & Alignment.Bottom) != 0)
            {
                y = BokuGame.height - font.LineHeight * (lines - line) - font.LineHeight / 2; // some spacing
            }
            else
            {
                y = (BokuGame.height - font.LineHeight) / 2 + (lines / 2 - line) * font.LineHeight;
            }
        }
示例#2
0
        protected void DrawText(int x, int y, Boku.Common.BitmapFont font, string label, Color color)
        {
            font.DrawString(x - 2, y - 1, Color.DarkGray, label);
            font.DrawString(x + 2, y - 1, Color.Gray, label);
            font.DrawString(x - 2, y + 1, Color.Gray, label);
            font.DrawString(x + 2, y + 1, Color.DimGray, label);

            font.DrawString(x, y, color, label);
        }
示例#3
0
        public override void Render()
        {
            // render Hint
            //
            int x;
            int y;

            // draw the title
            Boku.Common.BitmapFont font = BokuGame.fontBerlinSansFBDemiBold20;
            ArrayList lines             = Boku.Common.TextHelper.SplitMessage(this.title, BokuGame.width - font.LineHeight, font);

            for (int indexLine = 0; indexLine < lines.Count; indexLine++)
            {
                string textLine = lines[indexLine] as string;
                CalcTextPosition(out x, out y, font, textLine, indexLine, lines.Count);
                DrawText(x, y, font, textLine, Color.Yellow);
            }
        }
示例#4
0
        public override void Render()
        {
            // render instruction
            //
            int x;
            int y;

            // draw the title
            Boku.Common.BitmapFont font = BokuGame.fontBerlinSansFBDemiBold24;
            CalcTextPosition(out x, out y, font, this.title, 0, 1);
            DrawText(x, y, font, this.title, Color.White);

            // draw the text
            font = BokuGame.fontBerlinSansFBDemiBold20;
            ArrayList lines = Boku.Common.TextHelper.SplitMessage(this.text, BokuGame.width - font.LineHeight, font);

            for (int indexLine = 0; indexLine < lines.Count; indexLine++)
            {
                string textLine = lines[indexLine] as string;
                CalcTextPosition(out x, out y, font, textLine, indexLine, lines.Count);
                y += font.LineHeight * 2; // offset from title
                DrawText(x, y, font, textLine, Color.SkyBlue);
            }
        }